Getting error as "refresh_token is invalid" when trying to renew the access_token after 1hr expiry

I am using the Cloud REST Apis. I have created OAuth App in the developer console.

I acquire the access token using the grant_type = authorization_code method

Scope = ‘read:jira-user read:jira-work write:jira-work read:project:jira offline_access’

I get the access_token and the refresh_token in the response and it is saved in my database. The expiry is 3600 for the access token.

Within that 1 hour if I try to renew the access_token, it works perfectly fine.

But the problem occurs after 1 hour. As soon as the API is called for getting the list of projects, the 401 is returned saying the token is invalid. This is understood and for that I have written the interceptors to acquire new access_token using the refresh_token when a 401 is returned from JIRA APIs.

When I try to call the API (to refresh the access_token)

Following is the config I sent with my request.

const data = {

grant_type: 'refresh_token',

client_id: process.env.JIRA_CLIENT_ID,

client_secret: process.env.JIRA_CLIENT_SECRET,

refresh_token: userMetaDataValueObj.refresh_token,

redirect_uri: process.env.JIRA_REDIRECTURI,

access_type: 'offline',


const config = {

method: 'post',

url: '',

headers: {

'Content-Type': 'application/json',


data: data,


await axios(config)

I am getting the error as follow.


error: 'unauthorized_client',

error_description: 'refresh_token is invalid'

1 Like