Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Get User Profile using Graph API #2722

Closed
jyoti-r-4 opened this issue Oct 23, 2024 · 2 comments
Closed

Get User Profile using Graph API #2722

jyoti-r-4 opened this issue Oct 23, 2024 · 2 comments
Labels
for:MS-Q&A An issue that's better suited for Microsoft Q&A Needs: Attention 👋 Question: API

Comments

@jyoti-r-4
Copy link

jyoti-r-4 commented Oct 23, 2024

Hello Team,
I'm trying to get the user profile such as display name, email id, phone number using graph API. I'm following this document for reference.

First of all I'm generating an access token using the below curl command:

curl --location 'https://login.microsoftonline.com/<tenant-id>/oauth2/v2.0/token' \
--header 'Content-Type: application/x-www-form-urlencoded' \
--data-urlencode 'client_id=<client-id>' \
--data-urlencode 'client_secret=<client-secret>' \
--data-urlencode 'scope=https://graph.microsoft.com/.default' \
--data-urlencode 'grant_type=client_credentials'

Next, using the access_key from the above API, calling another /user API.

curl --location 'https://graph.microsoft.com/v1.0/users/<user-id>' \
--header 'Authorization: Bearer <access_key>'

I'm getting below error:

{
    "error": {
        "code": "Authorization_RequestDenied",
        "message": "Insufficient privileges to complete the operation.",
        "innerError": {
            "date": "2024-10-23T05:27:38",
            "request-id": <request-id>,
            "client-request-id": <client-request-id>
        }
    }
}

In my App Registration > Selected App > API Permission > Microsoft Graph API, I've following permissions:
User.Read.All Application Permission with Admin Consent as 'Yes'.

Is there any way to get the user profile using graph API? If my path is wrong, then suggest me a way to do it.

@andrueastman
Copy link
Member

Thanks for raising this @jyoti-r-4

As this is an API related question and this repo is mainly intended for MSGraph C# SDK related issues, any chance you can post the same question at the link below?

https://aka.ms/askGraph

@andrueastman andrueastman added status:waiting-for-author-feedback Issue that we've responded but needs author feedback to close Question: API for:MS-Q&A An issue that's better suited for Microsoft Q&A labels Oct 23, 2024
@jyoti-r-4
Copy link
Author

Thanks @andrueastman .

@microsoft-github-policy-service microsoft-github-policy-service bot added Needs: Attention 👋 and removed status:waiting-for-author-feedback Issue that we've responded but needs author feedback to close labels Oct 23, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
for:MS-Q&A An issue that's better suited for Microsoft Q&A Needs: Attention 👋 Question: API
Projects
None yet
Development

No branches or pull requests

2 participants