How to fix "/me request is only valid with delegated authentication flow." issue?

Jie Shen 61 Reputation points
2022-05-17T05:37:12.237+00:00

I want use postman to get user profiles from Azure AD.
I can got Token using [https://login.microsoftonline.com/{tenantID}/oauth2/v2.0/token]
But I couldn't get me profiles using [https://graph.microsoft.com/v1.0/me]
I got error as below.
/me request is only valid with delegated authentication flow.
I set API Access permissions as below.
User.Read (Delegated)
User.Read.All (Delegated)

Microsoft Graph
Microsoft Graph
A Microsoft programmability model that exposes REST APIs and client libraries to access data on Microsoft 365 services.
12,227 questions
Microsoft Entra ID
Microsoft Entra ID
A Microsoft Entra identity service that provides identity management and access control capabilities. Replaces Azure Active Directory.
22,072 questions
{count} votes

4 answers

Sort by: Most helpful
  1. Shweta Mathur 29,776 Reputation points Microsoft Employee
    2022-05-17T11:02:50.727+00:00

    Hi @Jie Shen ,

    Thanks for reaching out.

    I understand you are trying to call "/me" endpoint and added delegated permissions to access graph API "/me" endpoint, but you are getting error

    "/me request is only valid with delegated authentication flow".

    First you need to understand the delegated permissions and application permissions .

    Delegated permissions are used by those application which require user interaction or signed in by user whereas application permissions do not require any user interaction and used by those applications which run in the background and consented by admin only beforehand.

    Now, to call any API endpoint, we need to get access token with required permissions using different OAuth flows provided by Microsoft Identity Platform. As mentioned by michev, client credential flow does not require user interaction and require application permissions to get the access token.

    If you are trying to get the token with that flow, that token does not contain required permissions to call "/me" endpoint.

    To call "/me" endpoint, you need to get the access token using authorization grant flow, implicit flow or ROPC flow where user need to sign in to get the access token.

    Hope this will help.

    Thanks,
    Shweta

    ---------------------------------

    Please remember to "Accept Answer" if answer helped you.

    3 people found this answer helpful.

  2. Vasil Michev 107.3K Reputation points MVP
    2022-05-17T06:29:41.777+00:00

    There's nothing to fix here, the "/me" endpoint refers to the user in whose context you are running request, thus is only available for delegate permission flows. If you are using the application permissions model (client credentials), you are running your code without any user context, so there is no user to "resolve" for the "/me" endpoint. Use /users/{userId} instead.

    2 people found this answer helpful.

  3. Pritam K 5 Reputation points
    2024-05-30T09:28:37.6533333+00:00

    Below permissions needed and admin consent also required

    User's image

    1 person found this answer helpful.

  4. hasan radi 0 Reputation points
    2024-06-28T19:05:31.4266667+00:00

    Hi,

    I have the same issue, anyone can help me please?

    0 comments No comments

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.