2

I am writing a Teams-Slack integration. The point is to get our Shifts defined in MS Teams and change the descriptions of certain Slack channels according to who is on Shift.

In any case, the Slack end is all done, but I'm having a lot of issues with Teams and their API.

First of all, this is my main resource: https://learn.microsoft.com/en-us/graph/api/schedule-list-shifts?view=graph-rest-beta

Okay so here's what I've already done.

  • I have registered my bot in Azure and I have an ID
  • I have given the bot the required permissions
  • I have found the Teams group ID for our shifts

And this is how the process is done by hand:

  1. Navigate to a URL which will give me my code. I've attached a picture instead of a big URL jumble List item

  2. When I navigate to this URL (not using Python), I reach a page which makes me confirm my O365 User. (When Python tries this, it asks for a complete Log-In) enter image description here

  3. I then get redirected to the localhost page with a parameter code=SOMECODEHERE
  4. I then get this code and send it in a POST request using Postman in order to get my access token:

enter image description here

  1. I then use this bearer access token to pull the shifts.

Here are my issues/questions:

  1. When I eventually get my JSON file with all the team members' shifts, it only shows shifts for 1 month back and before. Aka today is 22-04-2019 and the last shift I can see is 22-03-2019.
  2. The JSON also doesn't show who is on-shift or On-call. I mean, I can see that there IS a shift on say 20-02-2019, but it doesn't return any UIDs or Names for the members who are on that shift. Is there any way to find this?
  3. Is there any way to get the "code=" value with python? It asks it to log in (as it asks me to confirm my O365 user - see 2nd image). Do I really need to hardcode my own login details so a bot can navigate to a page? That is dumb imo. I know I can read the redirected URL but I can't even get there.

1 Answer 1

1

This is only an answer for your third question. I'll see if I can find someone with answers to the first two.

The API you are accessing uses delegated permissions, meaning you are accessing on behalf of the logged-in user. When the user logs on, their identity is validated, and once that's true Azure AD returns the code you can exchange for an access token. Therefore, by definition, there is no way to get the code without having a user log in.

There is another kind of permission, application permission, which is not supported by this API, but if it was, would work the way you want. I'll ask about that too.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.