# The authorisation code is expired or invalid

**URL:** <https://devforum.okta.com/t/the-authorisation-code-is-expired-or-invalid/8120>\
**Category:** Questions\
**Created:** [February 17, 2020, 10:05am UTC](https://devforum.okta.com/t/the-authorisation-code-is-expired-or-invalid/8120 "2020-02-17T10:05:44Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![snsinha](https://avatars.discourse-cdn.com/v4/letter/s/b38774/32.png) [@snsinha](https://devforum.okta.com/u/snsinha)\
**Post date:** [February 17, 2020, 10:05am UTC](https://devforum.okta.com/t/the-authorisation-code-is-expired-or-invalid/8120/1 "2020-02-17T10:05:44Z")

</div>

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](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?

---

<div class="post-metadata">

**Author:** ![dragos](https://sea1.discourse-cdn.com/oktadev/user_avatar/devforum.okta.com/dragos/32/1313_2.png) [@dragos](https://devforum.okta.com/u/dragos)\
**Post date:** [February 18, 2020, 5:07am UTC](https://devforum.okta.com/t/the-authorisation-code-is-expired-or-invalid/8120/2 "2020-02-18T05:07:07Z")

</div>

Hi @snsinha

The authorization code used in the authorization code flow is available for one minute and can be used only once in order to exchange it for JSON Web Tokens.

---

<div class="post-metadata">

**Author:** ![snsinha](https://avatars.discourse-cdn.com/v4/letter/s/b38774/32.png) [@snsinha](https://devforum.okta.com/u/snsinha)\
**Post date:** [February 18, 2020, 5:54am UTC](https://devforum.okta.com/t/the-authorisation-code-is-expired-or-invalid/8120/3 "2020-02-18T05:54:48Z")

</div>

Yes.I understand that. Infact the GET request for the code and token url are in the same flow .So its definitely lesser than 1 minutes.

---

<div class="post-metadata">

**Author:** ![dragos](https://sea1.discourse-cdn.com/oktadev/user_avatar/devforum.okta.com/dragos/32/1313_2.png) [@dragos](https://devforum.okta.com/u/dragos)\
**Post date:** [February 18, 2020, 5:56am UTC](https://devforum.okta.com/t/the-authorisation-code-is-expired-or-invalid/8120/4 "2020-02-18T05:56:26Z")

</div>

Hi @snsinha

Can you please open a support case with us through an email to [developers@okta.com](mailto:developers@okta.com) in order to further check the tenant logs and see the authorization code requests?

---

<div class="post-metadata">

**Author:** ![system](https://global.discourse-cdn.com/oktadev/original/1X/589c4c5f80de422d01f47cee7185a7fb8227835c.png) [@system](https://devforum.okta.com/u/system)\
**Post date:** [January 24, 2024, 6:47pm UTC](https://devforum.okta.com/t/the-authorisation-code-is-expired-or-invalid/8120/5 "2024-01-24T18:47:33Z")

</div>

Closed on January 24, 2024, 6:47pm UTC

This topic was automatically closed 24 hours after the last reply. New replies are no longer allowed.
