Skip to content

Commit 335a848

Browse files
authored
Merge pull request #8658 from genlin/main4607
AB#4607 error-call-me-endpoint-microsoft-graph
2 parents a67b6b2 + 460dc8d commit 335a848

File tree

3 files changed

+67
-0
lines changed

3 files changed

+67
-0
lines changed
Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
---
2+
title: NoPermissionsInAccessToken when calling me endpoint in Microsoft Graph
3+
description: Describes an issue in which you receive `NoPermissionsInAccessToken` error when you call `/me` endpoint in Microsoft Graph.
4+
ms.date: 04/03/2025
5+
ms.service: entra-id
6+
ms.author: bhvootla
7+
ms.custom: sap:Getting access denied errors (Authorization)
8+
ms.reviewer: nualex,vganga,adoyle,custorod
9+
---
10+
# NoPermissionsInAccessToken when calling /me endpoint
11+
12+
This article discusses an issue in which you receive a `NoPermissionsInAccessToken` error message when you call the `/me` endpoint in Microsoft Graph. This article also explains why you can't call the `/me` endpoint by using a token that is acquired through the client credentials grant flow.
13+
14+
## Symptoms
15+
16+
When you try to call the `/me` endpoint from your Microsoft Entra ID-based application that uses [client credentials grant flow](/entra/identity-platform/v2-oauth2-client-creds-grant-flow), you receive the following error message:
17+
18+
```output
19+
{
20+
"error": {
21+
"code": "NoPermissionsInAccessToken",
22+
"message": "The token contains no permissions, or permissions can not be understood.",
23+
"innerError": {
24+
"oAuthEventOperationId": "48f66de9-xxx-xxxx1-xxxx-399ea6608ec0",
25+
"oAuthEventcV": "MkVd0xxxxxvjGFVJkoA.1",
26+
"errorUrl": "https://aka.ms/autherrors#error-InvalidGrant",
27+
"requestId": "80f8a0e9-xxxx-xxxx-xxxx-88e5d4bb5bb2",
28+
"date": "2021-07-30T04:04:38"
29+
}
30+
}
31+
}
32+
```
33+
34+
## Cause
35+
36+
The `/me` endpoint is designed to enable signed-in users to retrieve their own information. To call the `/me` endpoint, you must provide some user context because the endpoint uses delegated permissions. That is, a token that's generated by using the client credentials grant flow can't use the `/me` endpoint because the user context information is absent.
37+
38+
Tokens that are obtained by using the client credentials grant flow represent application identities, not user identities. These tokens contain a **roles** claim for application permissions instead of a scp (scopes) claim for delegated permissions. The absence of user context makes it impossible for the `/me` endpoint to determine the user who is associated with the request.
39+
40+
### Example tokens
41+
42+
**Token with user context (delegated flow with a user signed in)**
43+
44+
This token is granted by using delegated flow to which a user signed in. It contains user-specific information and a `scp` claim that contains the current user's permissions.
45+
46+
:::image type="content" source="media/error-call-me-endpoint-microsoft-graph/token-sign-in-user-context.png" alt-text="Screenshot that shows a delegated token example." lightbox="media/error-call-me-endpoint-microsoft-graph/token-sign-in-user-context.png":::
47+
48+
**Token with application identity (client_credentials grant flow)**
49+
50+
This token is generated by using the client credentials grant flow. It doesn't contain user-specific information. Instead, it contains a `roles` claim for application permissions.
51+
52+
:::image type="content" source="media/error-call-me-endpoint-microsoft-graph/token-application-context.png" alt-text="Screenshot that shows an application token example." lightbox="media/error-call-me-endpoint-microsoft-graph/token-application-context.png":::
53+
54+
## Solution
55+
56+
When you use the client credentials grant flow in your application, you must use the `/users` endpoint instead of the `/me` endpoint. The `/users` endpoint enables you to retrieve user-specific information by using application tokens.
57+
58+
For example, if you want to call `GET https://graph.microsoft.com/v1.0/me/memberOf` to generate a list of groups that a user is a member of, use the following method:
59+
60+
1. Obtain an application token by using the client credentials grant flow.
61+
2. Make sure that the application has the **User.Read.All** permission to query user information.
62+
3. Use the **users** endpoint to query specific user details. Replace {upn} with the User Principal Name (UPN) or User Object ID of the user.
63+
```HTTP
64+
GET https://graph.microsoft.com/v1.0/users/{upn or userID}/memberOf
65+
```
66+
67+
[!INCLUDE [Azure Help Support](../../../includes/azure-help-support.md)]
83.3 KB
Loading
134 KB
Loading

0 commit comments

Comments
 (0)