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
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?
- For the method, select GET (1)
- For the URI, enter
https://login.microsoftonline.com/<TENANT ID>/oauth2/token
(2) - On the
Headers tab
(3) addContent-Type
key andapplication/x-www-form-urlencoded
for the value (4)
- Switch to the
Body tab
, and add the following keys and values.- Select
form-data
- Add
grant_type
key, and typeclient_credentials
for the value. - Add
client_id
key, and paste the value ofclient ID
you noted down earlier. - Add
client_secret
key, and paste the value of client secret you noted down earlier.
- Select
- Select
Send
to send the request to get the token