Why I am getting HTTP 404 Not Found for getting access token using Mircrosft Graph API

I am trying to get access token using microsoft graph api via postman. I have provided client id and client secret (please refer to the attached screenshot). I am getting http 404 not found error. I am using following endpoint for fetching access token.

https://login.microsoftonline.com/{{TenantID}}/oauth2/v2.0/token

API request parameters

Api response

I trying write a function that will fetch the access token and then I will making another function call which will files from a sharepoint folder.

You can follow the first part of this article from Microsoft Learn.

Are you sure you set Content-Type to application/x-www-form-urlencoded in the headers?

token with postman

  • For the method, select GET (1)
  • For the URI, enter https://login.microsoftonline.com/<TENANT ID>/oauth2/token (2)
  • On the Headers tab (3) add Content-Type key and application/x-www-form-urlencoded for the value (4)

body tab

  • Switch to the Body tab, and add the following keys and values.
    • Select form-data
    • Add grant_type key, and type client_credentials for the value.
    • Add client_id key, and paste the value of client ID you noted down earlier.
    • Add client_secret key, and paste the value of client secret you noted down earlier.
  • Select Send to send the request to get the token

Leave a Comment