I created a SPA application in Azure AD and trying to generate access token via PKCE flow from postman.
I am following this msdoc : Microsoft identity platform and OAuth 2.0 authorization code flow - Microsoft Entra | Microsoft Docs
To generate code, I am using below authorize endpoint as mentioned in above document like
https://login.microsoftonline.com/{tenant}/oauth2/v2.0/authorize?
client_id=myclientid
&response_type=code
&redirect_uri=myredirecturi
&response_mode=query
&scope=https://graph.microsoft.com/.default
&code_challenge=YTFjNjI1OWYzMzA3MTI4ZDY2Njg5M2RkNmVjNDE5YmEyZGRhOGYyM2IzNjdmZWFhMTQ1ODg3NDcxY2Nl
&code_challenge_method=S256
But I am getting error like below:
AADSTS501491: Invalid size of Code_Challenge parameter.
What is the valid value for code_challenge parameter and how to generate it?
This error "Invalid size of Code_Challenge parameter." usually occurs if the code_challenge
is invalid. Make sure to generate a valid code_ challenge.
To generate code_challenge
, you can make use of this tool like below:
I tried in my environment and got the code value successfully including the above the code challenge value:
Make sure to include origin
header like below:
After including all the required parameters, I was able to generate access token successfully via PKCE flow from Postman like below: