Introduction
Hi guys, let’s learn an amazing way of handling the below MS Graph sample query errors when run on https://developer.microsoft.com/en-us/graph/graph-explorer
- Bad Requests
- Failure Status
- "code": "InvalidAuthenticationToken"
First, go through the errors and their descriptions for a better understanding:
https://docs.microsoft.com/en-us/graph/errors
Let’s start with a basic query.
UPN means - userPrincipalName
https://graph.microsoft.com/v1.0/users/UPN
First, check here.
Get your UPN for that specific Employee
UPN mostly is an email, like [email protected]
Now use it as shown here.

https://graph.microsoft.com/v1.0/me/messages?$count=true
Sample Teams Error Case
Run your Sample Query: GET https://graph.microsoft.com/v1.0/me/joinedTeams

Check the Error Message
Copy the keyword: joinedTeams here.
Search for related permissions information in the above link using that Key word which will redirect to another link, as shown here.
Make a note of the Permissions to be assigned:
|
Permission type
|
Permissions (from least to most privileged)
|
|
Delegated (work or school account)
|
User.Read.All, User.ReadWrite.All
|
|
Delegated (personal Microsoft account)
|
Not supported.
|
|
Application
|
User.Read.All, User.ReadWrite.All
|
Go to modify your permissions section mentioned in the failure status code message by clicking on it.
It can be handled by assigning permissions.
Enable them and run the same query again.
Sample Planner Error Case
Run one more Planner based Query for a specific Planner ID, and follow some steps above.
You should receive a successful output once again!
The above sample queries can be extended to be applied on the application level, which again needs to be handled by providing respective permissions by following the same kind of above process/check some related Articles/Blogs on that. Azure Application resource permission also needs to be handled through the Azure Portal.
Conclusion
Once the above errors are handled at the Application/Delegated level, we are good to make graph-oriented tasks and integrate them with Planner/Teams/Outlook related works to build effective business solutions.
Happy MS Graph API Application Developing with the above best practices! Cheers!

Join the conversation! Your thoughts help the community grow.