Search code examples
microsoft-graph-apimicrosoft-teamsmicrosoft-graph-teamsmicrosoft-graph-files

How can a user get a working token from Microsoft Graph?


I am making an application for Microsoft Teams.

Must get the teams in Microsoft Teams that the user is a direct member of. If I use the same email under which I registered the application in Active Directory, then getting the list on request to /me/joinedTeams is not difficult. However, if I am using someone else's Teams account, I get an UnknownError when requesting /me/joinedTeams.

I noticed that after consent and authorization in the Microsoft Graph, the user has a token shorter than mine.

However, it works with other endpoints (/me and /drive/root). Permissions are exposed in accordance with the documentation.

Permissions:

Directory.Read.All
Directory.ReadWrite.All
email
Files.Read
Files.Read.All
Files.Read.Selected
Group.Read.All
Group.ReadWrite.All
offline_access
openid
profile
Team.ReadBasic.All
TeamsAppInstallation.ReadWriteSelfForChat.All
TeamsAppInstallation.ReadWriteSelfForTeam.All
TeamsAppInstallation.ReadWriteSelfForUser.All
TeamSettings.Read.All
TeamSettings.ReadWrite.All
User.Read
User.Read.All
User.ReadWrite.All

enter image description here


Solution

  • Here you are getting the error because the /me/joinedTeams doesn't support personal accounts. See this document.

    It works for /me and /drive/root because it supports personal accounts. See this document and this document.