Azure AD Single Sign In - invalid_grant 9002313 when requesting token with code
May 22
We have an existing solution with ASP .NET Core and Angular frontend, with our own user management. Now I want to implement registration and login with Azure Active Directory.
I've successfully set up the AD application and the frontend logic to acquire the code. Then I pass it to our backend, to generate a token together with the secret. When calling the /oauth2/token endpoint, I get this error
{
"error": "invalid_grant",
"error_description": "AADSTS9002313: Invalid request. Request is malformed or invalid.\r\nTrace ID: 0a741bc7-c4a7-4699-af50-4e95a5690b00\r\nCorrelation ID: b83b609c-7cdc-4ad6-ae88-6aa07b4243f8\r\nTimestamp: 2020-05-22 19:22:24Z",
"error_codes": [
9002313
],
"timestamp": "2020-05-22 19:22:24Z",
"trace_id": "0a741bc7-c4a7-4699-af50-4e95a5690b00",
"correlation_id": "b83b609c-7cdc-4ad6-ae88-6aa07b4243f8",
"error_uri": "https://login.microsoftonline.com/error?code=9002313"
}
I could reproduce the problem with Postman. I tried the tenantid (Guid) as well as the name xxx.onmicrosoft.com
1 answer
Accepted answer · original discussion
May 25
You follow my process to try to get the code:
First register the application,Go to azure portal:
Then enter this link in the browser to get the code:
https://login.microsoftonline.com/{tenant}/oauth2/authorize?
client_id={your-client-id}
&response_type=code
&redirect_uri=https://localhost:4500/web/completeoauth/ms
&response_mode=query
&state=12345
Finally use postman to get the access token(Configure as per my request):
Hope can help you!
0 question comments
Use comments to ask for clarification. Post a solution as an answer.
No question comments on this page.