Skip to content

Exchange code for authorization token failed #69

Open
@ihorhrechka

Description

@ihorhrechka

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions