Search code examples
azure-active-directorymicrosoft-graph-apimicrosoft-teamsunauthorized

'Unauthorized' error when requesting 'https://graph.microsoft.com/v1.0/me/joinedTeams' from Microsoft Graph


I am trying to access https://graph.microsoft.com/v1.0/me/joinedTeams in postman with Authorization and I'm getting the response as

{ "error": { "code": "Unauthorized", "message": "Unauthorized", "innerError": { "date": "2020-08-01T09:39:59", "request-id": "d906f428-ffcd-4821-9153-f9b1976e74c1" } } }

As mentioned in the documentation, I have set the scopes Team.ReadBasic.All TeamSettings.Read.All TeamSettings.ReadWrite.All User.Read.All User.ReadWrite.All Directory.Read.All Directory.ReadWrite.All Group.Read.All Group.ReadWrite.All ChannelMessage.Send

In the Enterprise applications, I'm having Microsoft teams installed

I have added the API permissions for type Delegated

But I can access the profile and groups. whenever I try to access teams API, I'm always getting Unauthorized message. Can anyone tell me, What am I missing?


Solution

  • I notice that you haven't granted admin consent for your tenant. You should use an Azure AD admin account to do this. The the Status will become "Granted for {your tenant}".

    enter image description here

    You should refer to Get access on behalf of a user to get the access token by using auth code flow.

    enter image description here