Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Unable to generate authorization code via PKCE flow for SPA

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?

like image 392
17 revs Avatar asked Dec 19 '25 07:12

17 revs


1 Answers

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:

enter image description here

I tried in my environment and got the code value successfully including the above the code challenge value:

enter image description here

Make sure to include origin header like below:

enter image description here

After including all the required parameters, I was able to generate access token successfully via PKCE flow from Postman like below:

enter image description here

like image 128
Rukmini Avatar answered Dec 21 '25 03:12

Rukmini



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!