Unable to authenticate to graph api using client credentials flow

Shajedul Alam 0 Reputation points
2025-01-10T20:38:59.8866667+00:00

Hello,

I am unable to authenticate to our registered app in azure. I am looking to test the get/users graph api uisng insomnia (similar tool as postman).
https://learn.microsoft.com/en-us/graph/api/user-revokesigninsessions?view=graph-rest-1.0&tabs=http#http-request

I created the app, added the necessary permissions and the client credentials. Do I need to add a redirect uri to the app? Does the app need to be registered account types as "accounts in any organization directory"?

I am getting a 401 unauthorized error Can you please assist im what is missing here?

Microsoft Security | Microsoft Graph
0 comments No comments

1 answer

Sort by: Most helpful
  1. CarlZhao-MSFT 46,456 Reputation points
    2025-01-13T02:48:46.27+00:00

    Hi @Shajedul Alam

    You don't need to add a redirect URL, because the client credentials flow does not involve user interaction. You also don't need to register your app as "supports accounts from any organization" unless you want to share your app with other organizations.

    If you are using the client credentials flow, then make sure you are calling the /users/{id | userPrincipalName} endpoint instead of the /me endpoint, otherwise it will throw a 401 "Unauthorized" error. Also, don't forget to grant the corresponding application permissions for the calling app.


    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.

    Was this answer helpful?


Your answer

Answers can be marked as 'Accepted' by the question author and 'Recommended' by moderators, which helps users know the answer solved the author's problem.