Skip to main content
Skip table of contents

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

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.

Step1: Create OAuth2 integration

Create an Application

  • Go to the Atlassian Developer Console

  • Create a new application and give it a name:

    Atlassian Developer Console
  • 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

Authorization Setup

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

    Atlassian Developer Console
  • 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.

  • Copy the generated authorization URL and paste it into a text editor for modification:

Atlassian Developer Console

Step2: Obtain authorization code grants

  • Modify the authorization URL by adding the offline_access scope. Example:

    CODE
    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:

    Autorization Code in URL

Step 3: Obtain access token and refresh token

  • The final step in obtaining all the necessary information is to manually retrieve the Access Token and the Refresh Token. To do this, enter 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 this:

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 together all the information from the previous steps:

  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.

    Adding the Datasource in PocketQuery

Step 5: Create a Query and a 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!

That’s it! 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.