GET user Id via PrincipalUserName

tyler cushing 40 Reputation points
2023-10-06T16:55:42.4966667+00:00

I have a callout that gets a Microsoft User Id via "https://graph.microsoft.com/v1.0/users/" + Email (Principal User Id)

I have confirmed I have the correct permissions User.Read.All, and I my Authorization callout is working correctly. Here's what I have:

GET: 
https://graph.microsoft.com/v1.0/users/validEmail%40validDomain.com
HEADERS:
Authorization = Bearer {{AuthToken}}
Content-Type = application/json

And here is what I am getting:

{
    "error": {
        "code": "Authorization_RequestDenied",
        "message": "Insufficient privileges to complete the operation.",
        "innerError": {
            "date": "2023-10-06T16:48:12",
            "request-id": "123...",
            "client-request-id": "123..."
        }
    }
}

Any help or ideas are appreciated!

Microsoft Graph
Microsoft Graph
A Microsoft programmability model that exposes REST APIs and client libraries to access data on Microsoft 365 services.
11,449 questions
0 comments No comments
{count} votes

Accepted answer
  1. CarlZhao-MSFT 40,311 Reputation points
    2023-10-09T02:52:22.4766667+00:00

    Hi @tyler cushing

    Are you granting application permissions? It seems like you are trying to get other user's information, then you should grant application permissions to the calling app instead of delegate permissions. Please check.

    6

    Next, you need to request an access token using the daemon-based client credentials flow.

    Call API:

    User's image

    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.


0 additional answers

Sort by: Most helpful