Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Exchange code for authorization token failed #69

Open
ihorhrechka opened this issue Oct 28, 2024 · 0 comments
Open

Exchange code for authorization token failed #69

ihorhrechka opened this issue Oct 28, 2024 · 0 comments

Comments

@ihorhrechka
Copy link

Was trying to deploy to AWS Lambda (Node.js 20.x) but it fails to exchange the code. It seems like it is required to provide the application/x-www-form-urlencoded content-type when sending request using axios.

So, changing this one in authn\openid.index.js:

const postData = qs.stringify(config.TOKEN_REQUEST);
axios.post(discoveryDocument.token_endpoint, postData).then(...)

to this one:

const params = new URLSearchParams();
params.append('grant_type', config.TOKEN_REQUEST.grant_type);
params.append('client_id', config.TOKEN_REQUEST.client_id);
params.append('redirect_uri', config.TOKEN_REQUEST.redirect_uri);
params.append('client_secret', config.TOKEN_REQUEST.client_secret);
params.append('code', config.TOKEN_REQUEST.code);
   
axios.post(discoveryDocument.token_endpoint, params, { headers: {'content-type': 'application/x-www-form-urlencoded'}}).then(...)	

makes it work for me.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant