Hey , I could make some changes and it worked on POSTMAN. Following is the URL is am using on POSTMAN. curl --location --request POST ‘https://dev-977966.okta.com/oauth2/default/v1/token’
–header ‘Accept: application/json’
–header ‘Content-Type: application/x-www-form-urlencoded’
–header ‘Authorization: Basic MG9hMTJxNDBwUVdkRWE5Qlg0eDY6NWVwTFBaSG1YYW1BY196bkZnbWtTR2ExS0FhT1JEMm5VOWhxd1VZUg==’
–data-urlencode ‘grant_type=authorization_code’
–data-urlencode ‘redirect_uri=http://localhost:8080/content-catalog/login’
–data-urlencode ‘code=uT1nmYBuPlHXFg1NRgUN’. But ,now when I used this in the node js project ,it throws ‘The authorisation code is invalid or has expired error’.I checked it on in the app logs as well but there is not sucessful token grant and just ‘The authorisation code is invalid or has expired error’.
return this.oauthApiClient.post(’/oauth2/default/v1/token’, {
payload: formData,
headers: {
‘Accept’: ‘application/json’,
‘Content-type’: ‘application/x-www-form-urlencoded’,
‘Authorization’: ${basicAuth}
}
}).then((oauthResponse) => {
const mysecret = this.oktaClient_secret || ‘none’;
request.log(‘Ankit ‘, oauthResponse);
// request.log(mysecret);
// request.log(oauthResponse.statusCode);
if (oauthResponse.statusCode !== 200) {
throw Invalid OAuth response (Status ${oauthResponse.statusCode} / ${mysecret.substring(0, 3)}...${mysecret.substring(mysecret.length - 3)}): ${JSON.stringify(oauthResponse.payload)}
;
}
if (!(‘access_token’ in oauthResponse.payload)) {
request.log(‘sneha4’);
throw Invalid OAuth response: ${JSON.stringify(oauthResponse.payload)}
;
}
console.log(’&&&&’);
const token = oauthResponse.payload.access_token;
this.id_token = oauthResponse.payload.id_token;
return this.verify(token).then((decoded) => {
return {
…decoded,
token
};
});
}).catch((error) =>
console.log(errorparidhi${JSON.stringify(error)}
));
}
This is the code.Can someone help me with this?