Microsoft Graph to access your Microsoft account

Kosowski, Damian 0 Reputation points
2024-04-08T11:29:03.43+00:00

When I am trying create sample app by following steps on https://developer.microsoft.com/en-us/graph/quick-start (connect to Microsoft 365 and call the Graph AP) I I get error:

User's image

I will only add that logging in is carried out correctly

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

1 answer

Sort by: Most helpful
  1. Deepanshu Sharma 495 Reputation points Microsoft Vendor
    2024-04-15T17:25:06.7566667+00:00

    Hello Daiman

    To access your Microsoft account using the Microsoft Graph API, you’ll need to follow these steps:

    1. Register Your App: Go to the Azure portal. Create a new App Registration. Note down the Application (client) ID and Directory (tenant) ID.
    2. Configure Permissions: In your app registration, navigate to API permissions. Add the necessary permissions based on the resources you want to access. Some common permissions include: User.Read: Read basic profile information of the signed-in user. Mail.Read: Read the user’s mailbox. Calendars.Read: Read the user’s calendar events. Adjust permissions according to your use case.
    3. Authentication Endpoint: The authentication endpoint for Microsoft Graph is:
           https://login.microsoftonline.com/{tenant-id}/oauth2/v2.0/authorize
           
      
      Replace {tenant-id} with your Directory (tenant) ID.
    4. Access Token Endpoint: To obtain an access token, make a POST request to the following endpoint:
           https://login.microsoftonline.com/{tenant-id}/oauth2/v2.0/token
           
      
      Include the required parameters: client_idscopeclient_secretgrant_type, and redirect_uri.
    5. Construct API Requests: Use the access token to construct requests to the Microsoft Graph API. The base URL is:
           https://graph.microsoft.com/v1.0/
           
      
      Append the specific resource path (e.g., /me/users/{user-id}/me/messages, etc.) to the base URL.
    6. Example Request: To get the current user’s profile:
           GET https://graph.microsoft.com/v1.0/me
           
      
    7. Interpret the Response: The response will be in JSON format. Parse it to extract the relevant data.
    0 comments No comments

Your answer

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