question

Sruthi-1846 avatar image
0 Votes"
Sruthi-1846 asked Givary-MSFT edited

Graph API GET /v1.0/users returns 401

I am using Graph API call to get the user info of our organisation. It returns 401 error code.

We are using Microsoft.Identity.Client that uses MSAL library.

Can you please help me in understanding why is it returning 401 HTTP response? By any chance due to many requests (throttling) does it return 401 instead of 429?

Thanks,
Sruthi

azure-ad-graphazure-ad-msalazure-ad-pass-through-authenticationmicrosoft-graph-throttling
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

1 Answer

Givary-MSFT avatar image
0 Votes"
Givary-MSFT answered

@Sruthi-1846

Thank you for reaching out to us. As I see you are getting error 401 while performing GET /v1.0/users to Graph API.

Error 401 is an Unauthorized error. Make sure that your application is presenting a valid access token to Microsoft Graph as part of the request. This error often means that the access token may be missing in the HTTP authenticate request header or that the token is invalid or has expired.

This error may occur, if you try to use a delegated access token granted to a personal Microsoft account, to access an API that only supports work or school accounts (organizational accounts).. Make sure you login using work account.

You can also check the answers already available on Microsoft Q&A for 401 errors - https://docs.microsoft.com/en-us/answers/search.html?c=&f=&includeChildren=&q=%5bmicrosoft-graph%5d+401+&redirect=search%2fsearch&sort=relevance&type=question+OR+idea+OR+kbentry+OR+answer+OR+topic+OR+user

https://docs.microsoft.com/en-us/answers/questions/759462/graph-api-34list-places34-give-401-error.html

Let me know if you have any questions.

Please remember to "Accept Answer" if answer helped, so that others in the community facing similar issues can easily find the solution.

5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.