Dmitry Kh
Dmitry Kh

Reputation: 136

Retrieving user info from AAD using Graph REST API for not B2C users

I need to get users' names knowing their Azure AD IDs. I was able to get this info by calling GET https://graph.microsoft.com/v1.0/users/{id}, but only for B2C users. If a user is not B2C I am getting a ServiceUnavailable response code.

Does it mean that I do not have permission?

Upvotes: 0

Views: 641

Answers (1)

Carl Zhao
Carl Zhao

Reputation: 9569

I think you may be using Azure AD B2C access token, because you are acquiring users of B2C tenants. The easiest way to check is to use jwt.ms to parse your access token, and then check the tid claim, it should be the tenant id of your B2C tenant.

If you want to obtain user information for non-B2C tenants, such as users of AD tenants, you only need to change the /tenant id endpoint to the id of the AD tenant , then use the application of the AD tenant. Finally you can use the client credential flow to obtain an access token. Use this token to call the api, you should be able to obtain information about non-B2C users.

Upvotes: 1

Related Questions