Error message: /me request is only valid with delegated authentication flow

Umar khalid 0 Reputation points
2023-09-02T14:53:53.4533333+00:00

i am trying to access calendars api's using a bearer token.

But I'm getting error and facing some difficulties.

Error message: /me request is only valid with delegated authentication flow

{
    "error": {
        "code": "BadRequest",
        "message": "/me request is only valid with delegated authentication flow.",
        "innerError": {
            "date": "2023-09-02T14:32:51",
            "request-id": "a4e632a7-3eea-48d0-944c-9d8f04a949cf",
            "client-request-id": "a4e632a7-3eea-48d0-944c-9d8f04a949cf"
        }
    }
}

Even though we granted all permissions in API permissions still we getting this error.

"roles": [
    "Calendars.Read",
    "Calendars.ReadBasic.All",
    "Calendars.ReadWrite"
  ],
Microsoft Teams | Development
Microsoft Security | Microsoft Entra | Microsoft Entra ID
Microsoft Security | Microsoft Graph
{count} votes

1 answer

Sort by: Most helpful
  1. CarlZhao-MSFT 46,371 Reputation points
    2023-09-04T02:22:08.3+00:00

    Hi @Umar khalid

    You are granting application permissions, and the /me endpoint only supports delegated permissions, and that's the problem.

    You should use the daemon-based client credentials flow for application permissions, and then change the /me endpoint to the /users/{user id} endpoint, since user logins don't exist for application-only context.

    If you want to call the /me endpoint to access the Calendar API, you should grant delegated permissions to the calling app and then use the delegated authentication flow to obtain an access token, such as auth code flow or ROPC flow.

    Hope this helps.

    If the reply is helpful, please click Accept Answer and kindly upvote it. If you have additional questions about this answer, please click Comment.

    1 person found this answer helpful.

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.