Microsoft Access Token Request Error - 400 Bad Request
For this kind of issue , as @RasmusW suggested , you could use a tool like Fiddler to find the inner error message in the response . And as @ Dan Kershaw pointed out , you need to make sure reply address url in token request should match the reply address in Authorization code request . Otherwise you will get the error : The reply address 'xxxxx' does not match the reply address 'xxxx' provided when requesting Authorization code.
According to your request , you are using the Authorization Code Flow with v2.0 endpoint . You must add a “grant_type” parameter in the token request , and the value must be “authorization_code” for the authorization code flow. Please check it first if the inner error message is “AADSTS90014: The request body must contain the following parameter: 'grant_type” . Please click here for more details about OAuth 2.0 Authorization Code Flow in v2.0 endpoint.
May i use personal Microsoft account with Microsoft Graph API
Yes .The v2.0 endpoint allow developers to write apps that accept sign-in from both Microsoft Accounts and Azure AD accounts, using a single auth endpoint.
Dhrutika Rathod
Updated on June 04, 2022Comments
-
Dhrutika Rathod almost 2 years
I am trying to get access token from access code. but there is a error of 400 Bad Request error
I am using this link to get Access code
in response of this link i am getting the code in query string with return url code=Mh12d04c8-8ea9-c82b-8cc5-b93cf913382c
i am using this code to get access token
But it is giving 400 Bad Request. please help me to solve this issue.
-
Dhrutika Rathod about 7 yearsThank you @Nan Yu - MSFT. and please help me that how to trace error in Fiddler?
-
Dhrutika Rathod about 7 yearscan you please provide me the code sample for this?
-
Nan Yu about 7 yearsFor how to use Fiddler to debug , you could get a lot of tutorials on the internet , for example , this one :asjava.com/tools/fiddler-tutorial-how-to-use-fiddler . For how to use Microsoft Graph API , you could click graph.microsoft.io/en-us/docs/authorization/auth_overview for code samples .
-
Dhrutika Rathod about 7 yearsThank you @Nan Yu - MSFT. it is working for me but as you given me the Microsoft Graph API link. i got the response as Unauthorized. and in Fiddler i got the response as "code=unauthenticated" and "message=Must be authenticated to use '/drive' syntax" when i use my Microsoft Account. Please help me for this.
-
Nan Yu about 7 years@Dhruti Rathod , Have you got the access token successfully , which api call you are using when you get the error ? You could check the microsoft graph api document ,check whether your access token has permissions to make your api call .
-
Dhrutika Rathod about 7 yearsyes i got the token successfully. and i am using "graph.microsoft.com/v1.0/me/drive" api call with Authorization "Authorization: Bearer <access token>". and i have given all permission as it is my personal Microsoft account.
-
Dhrutika Rathod about 7 yearsis it possible to access personal Microsoft account drive(not a Business account) items from "graph.microsoft.com" api?
-
Nan Yu about 7 years@Dhruti Rathod . Yes , you could use Microsoft Graph to access personal OneDrive with Active Directory OAuth v2 endpoints .You could check the detail steps from azure.microsoft.com/en-us/documentation/articles/… , You could use "https%3A%2F%2Fgraph.microsoft.com%2FFiles.read" scope for testing .
-
Nan Yu about 7 years@Dhruti Rathod Please mark this reply , so anyone else could refer to when they meet same error as yours.
-
Dhrutika Rathod about 7 yearsplease see my this question, stackoverflow.com/questions/42408512/… . i think you can surely help me. please help me. @Nan Yu - MSFT