Skip to main content
Skip table of contents

[REST OAuth 2.0 (3LO)] Jira Cloud API

What do you think about: This guide provides a step-by-step process to access your Jira Cloud data using REST OAuth 2. The official documentation can be found here https://developer.atlassian.com/cloud/jira/platform/oauth-2-3lo-apps/#overview.

Step1: Create OAuth2 integration

1.Create an Application:

Screenshot 2024-10-25 at 10.15.09.png
  • Add necessary scopes and authorization by clicking “Add” for the Jira API and then “Configure”.

Screenshot 2024-10-25 at 10.18.07.png
  • For this example, you could select the "View Jira issue data" scope.

Screenshot 2024-10-25 at 10.19.00.png

2.Authorization Setup:

  • Go to “Authorization” and click on “Add” for OAuth 2.0 (3LO)

Screenshot 2024-10-25 at 10.19.16.png
  • Provide a callback URL (e.g., http://example.com ) for authorization purposes.
    You can use example.com because we just need to copy the generated code after authorization for our page.

Screenshot 2024-10-25 at 10.20.02.png
  • Copy the generated authorization URL and paste it into a text editor for modification.

Step2: Obtain authorization code grants

  • Modify the authorization URL by adding the offline_access scope. Example:
    https://auth.atlassian.com/authorize?audience=api.atlassian.com&client_id=[client_id]&scope=read%3Ajira-work manage%3Ajira-project%20offline_access&redirect_uri=https%3A%2F%2Fexample.com&state=${YOUR_USER_BOUND_VALUE}&response_type=code&prompt=consent

  • Access the modified URL, select your page, and grant authorization.

Screenshot 2024-10-18 at 11.29.00.png
  • Copy the authorization code from the redirected URL, added as callback URL in an earlier step.

Screenshot 2024-10-18 at 11.29.17.png

Step 3: Obtain access token and refresh token

  • The last step to get all the necessary information is, to manually retrieve the access token and the refresh token. To do this, fill your client id, client secret and authorization code in the following command:

BASH
curl --request POST \
  --url 'https://auth.atlassian.com/oauth/token' \
  --header 'Content-Type: application/json' \
  --data '{"grant_type": "authorization_code","client_id": "yourclientid","client_secret": "yourclientsecret","code": "the previously obtained auth code","redirect_uri": "https://example.com"}'
  • The client secret can be found here:

Screenshot 2024-10-25 at 11.05.45.png

  • Execute the command in a terminal window. The response will look like that:

JSON
{
  "access_token": "...",
  "expires_in": 3600,
  "token_type": "Bearer",
  "refresh_token": "...",
  "scope": "manage:jira-project read:jira-work offline_access"
}

Step 4: Create Datasource

To add the datasource you need to bring all the information from the previous steps together:

  1. Base URL
    https://api.atlassian.com/ex/jira/[SITE_ID]/rest/api/2
    Find your SITE_ID at https://your-site-url.atlassian.net/_edge/tenant_info

  2. Test path /search

  3. Authentication URL https://auth.atlassian.com/oauth/token

  4. Client ID Available on your application's settings page.

  5. Client Secret Available on your application's settings page.

  6. Refresh Token From the previous step's response.

  7. Access Token From the previous step's response.

  8. Scope From the previous step's response.

Screenshot 2024-10-25 at 11.09.29.png

Step 5: Create Query and Converter

  • Query: Define your query to retrieve Jira issues.

Screenshot 2024-10-25 at 11.30.26.png
  • Converter: Use the following JavaScript function to convert JSON data:

Screenshot 2024-10-25 at 11.30.46.png
JS
function convert(json) {
  const parsed = JSON.parse(json);

  return parsed['issues'].map(issue => ({
    'Issue Key': issue.key,
    'Description': issue.fields.description,
  }));
}

Ready!

You can now use the query to view your Jira issues.

Screenshot 2024-10-25 at 11.45.23.png

JavaScript errors detected

Please note, these errors can depend on your browser setup.

If this problem persists, please contact our support.