Access Denied to Graph (despite valid access token and permissions)

josh j 0 Reputation points
2025-01-08T00:58:15.5833333+00:00

Hi,

I'm getting Access Denied for trying to do a GET request on https://graph.microsoft.com/v1.0/users/${userId}/messages

But I cant successfully get my emails from the graph API.

My App's permissions are as follows:

permissions

Why is the API still denying my access?

Outlook
Outlook
A family of Microsoft email and calendar products.
4,504 questions
Microsoft Graph
Microsoft Graph
A Microsoft programmability model that exposes REST APIs and client libraries to access data on Microsoft 365 services.
13,357 questions
{count} votes

2 answers

Sort by: Most helpful
  1. Andy David - MVP 153.9K Reputation points MVP
    2025-01-08T01:18:08.32+00:00
    0 comments No comments

  2. Yakun Huang-MSFT 10,555 Reputation points Microsoft External Staff
    2025-01-08T02:05:08.62+00:00

    Hello josh j,

    Thank you for reaching out to Microsoft Support!

    After testing, the test results are good, the endpoint is no problem, the test results are as follows:

    Screenshot 2025-01-08 015759

    For your error, please check the following:

    1.Try to use https://graph.microsoft.com/v1.0/me/messages or https://graph.microsoft.com/v1.0/users/ {userPrincipalName}/messages to list messages

    2.Try to use common endpoint access token https://login.microsoftonline.com/common/oauth2/v2.0/token

    3.Check whether the token has valid permissions and parse the token in jwt.ms, as shown in the following figure:

    Screenshot 2025-01-08 020201

    4.If you get messages from other users, you need to get authorization from other users

    User's image

    Reference document:

    https://learn.microsoft.com/en-us/graph/api/user-list-messages?view=graph-rest-1.0&tabs=http

    Hope this helps.

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

    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.