Graph API GET /v1.0/users returns 401

Sruthi 1 Reputation point
2022-05-20T18:17:39.007+00:00

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

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

1 answer

Sort by: Most helpful
  1. Givary-MSFT 28,321 Reputation points Microsoft Employee
    2022-05-21T15:08:23.82+00:00

    @Sruthi

    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://learn.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://learn.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.

    0 comments No comments