Graph API /me getting error

Daniel Jao 0 Reputation points
2023-01-23T14:01:52.6066667+00:00

Hi, I'm doing oauth of imap, here are the scopes im using:

https://outlook.office.com/SMTP.Send https://outlook.office.com/POP.AccessAsUser.All https://outlook.office.com/IMAP.AccessAsUser.All offline_access

I'm able to get the access_token and im able to generate new access token via the refresh token. So this is good.

But i want to get the user info, especially the "email", so im calling: https://graph.microsoft.com/v1.0/me api using the access_token in the header (Authorization: Bearer <access token>), but im getting an error:

it says:

CompactToken parsing failed with error code: 8004920A

Request ID: f0d10175-f759-4b48-8d07-d2cb873be7cf

Can someone help?

Thanks!

Microsoft Graph
Microsoft Graph
A Microsoft programmability model that exposes REST APIs and client libraries to access data on Microsoft 365 services.
13,059 questions
0 comments No comments
{count} votes

2 answers

Sort by: Most helpful
  1. Vasil Michev 113.8K Reputation points MVP
    2023-01-23T14:14:59.3133333+00:00

    You are mixing two sets of API endpoints here, both of which require a separate token. Try leveraging the matching Graph API scopes instead:

    https://graph.microsoft.com/IMAP.AccessAsUser.All
    https://graph.microsoft.com/SMTP.Send https://graph.microsoft.com/POP.AccessAsUser.All

    This way you will still have all the required permissions, but on a single endpoint, so a single token is needed.


  2. Daniel Jao 0 Reputation points
    2023-01-23T14:30:27.2733333+00:00

    Hi @Vasil Michev if i use the graph scopes, then ill lose access to the outlook api.

    my main goal is replace the imap access via app password, thus im using oauth, but i also need the user info (email and name) so i would not need to ask for it separately, how can i be able to do that? any suggestions?

    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.