How to get email of user if I have an access token with User.Read?

GZ 40 Reputation points
2024-09-16T13:09:52.2333333+00:00

Hi all,

I am able to perform an authorization code flow (see https://learn.microsoft.com/en-us/entra/identity-platform/v2-oauth2-auth-code-flow and https://learn.microsoft.com/en-us/graph/auth-v2-user?tabs=http) to get an access token with the 'https://graph.microsoft.com/User.Read' permission. I ma trying to figure out, using the Java API or using a GET call, how to get a users's email address. So quick questions:

  1. Did I request the right permission? If not, what permission should I request?
  2. What is the method that I have to call to get this data?

Thanks very much in advance for any help you give!

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

1 answer

Sort by: Most helpful
  1. Yakun Huang-MSFT 5,415 Reputation points Microsoft Vendor
    2024-09-18T06:05:36.5233333+00:00

    Hi @GZ

    You can obtain the user's email address you want through the List users endpoint. To access this endpoint, User.Read permission is not sufficient. You need to grant User.Read.All permission.

    You can refer to this document for more details.

    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.


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.