Unable to get refresh tokens in OAuth 2.0 Jira Service Desk integration

Viewed 250

I have enabled OAuth 2.0 and used the access token to call Jira Service Desk Rest endpoints.

Problem: access token expires every 1 hour. According to the documentation OAuth 2.0 there are 2 ways to get new access token when it expires

  • Initiate the entire authorization flow from the beginning again.
  • Use a refresh token to get another access token.

Step 1 does not make any sense as it redirects to webpage and manual intervention is required to authorise the app. To use Step 2 I dont get refresh token at all https://auth.atlassian.com/oauth/token

1 Answers

In general a short term access token is given. In order to get a long term refresh token offline_access scope should be specified in the the authorization URL to get an authorization code.

https://auth.atlassian.com/authorize?
  audience=api.atlassian.com&
  client_id=YOUR_CLIENT_ID&
  scope=REQUESTED_SCOPE_ONE%20REQUESTED_SCOPE_TWO&
  redirect_uri=https://YOUR_APP_CALLBACK_URL&
  state=YOUR_USER_BOUND_VALUE&
  response_type=code&
  prompt=consent

Here in scope it should be scope=REQUESTED_SCOPE_ONE%20REQUESTED_SCOPE_TWO%20offline_access&

Related