> ## Documentation Index
> Fetch the complete documentation index at: https://docs.refold.ai/llms.txt
> Use this file to discover all available pages before exploring further.

# Setup

> Connect to your Jira app for OAuth.

### Pre-requisites

1. Jira Developer Portal. You can create one [here](https://www.atlassian.com/developers).
2. Required Settings for the app. You can find it in [Overview](https://docs.gocobalt.io/resources/integration-providers/jira_overview#required-settings).

### Required Settings

* **Mandatory Scopes**

1. offline\_access
2. read:jira-work

<Info>If you haven't already created an app in Jira, you'd need to create one.</Info>

### Creating an app in Jira

To create a Jira app and acquire the above mentioned credentials, please follow the steps mentioned below:

1. Log in to your [Jira Developer Portal](https://developer.atlassian.com/console).
2. Click on the `Create` button in the right and select `OAuth 2.0 integration`.

<img height="200" src="https://mintcdn.com/cobalt-55/0IGKzTphHY-auv_h/images/Jira/jira_navigation.png?fit=max&auto=format&n=0IGKzTphHY-auv_h&q=85&s=8225ab62874be437288952b2a0147f2b" alt="Navigation for App setup" data-path="images/Jira/jira_navigation.png" />

3. Enter the **App Name** for your application, **agree** to the Developer's terms and click on `Create`.
4. Go to your [`Apps catalog`](https://app.gocobalt.io/apps) in Refold > Search for `Jira` > `Settings` > `Use your credentials` > `Callback Url` > Copy it.
5. Navigate to `Authorization` in the side menu > Click on `Add` button under **Action** > Paste the **Callback Url** > Click on `Save changes`.

<img height="200" src="https://mintcdn.com/cobalt-55/0IGKzTphHY-auv_h/images/Jira/jira_config.png?fit=max&auto=format&n=0IGKzTphHY-auv_h&q=85&s=7318d85840623a09e2b86c29ebe497e1" alt="Setting up Jira Developer app" data-path="images/Jira/jira_config.png" />

6. Navigate to `Permissions` in the side menu > Click on `Add` button in **Jira API** > Click on `Configure`.
7. Navigate to **Classic scopes** tab > Click on `Edit Scopes` button in **Jira platform REST API** > Select **read:jira-work** scope > Click on the `Save` button.

<img height="200" src="https://mintcdn.com/cobalt-55/0IGKzTphHY-auv_h/images/Jira/jira_setscopes.png?fit=max&auto=format&n=0IGKzTphHY-auv_h&q=85&s=30f708962090f810e1f107090b6149be" alt="Scopes Selection in Jira App" data-path="images/Jira/jira_setscopes.png" />

8. Navigate to `Distribution` in the side menu > Click on the `Edit` button > Change **distribution status** to `Sharing` and provide **Vendor and Security Details** > Click on `Save Changes`.

<Info>
  **Note**: Changing Distribution Status from Private to Sharing is necessary, otherwise only the Developer account user can install and use it.
</Info>

9. Navigate to `Settings` in the side menu, scroll down and copy the **Client ID** and **Secret** from **Authentication details** section.

<img height="200" src="https://mintcdn.com/cobalt-55/0IGKzTphHY-auv_h/images/Jira/jira_credentials.png?fit=max&auto=format&n=0IGKzTphHY-auv_h&q=85&s=f61081618926a9d3198ff79607b999ae" alt="Getting Credentials" data-path="images/Jira/jira_credentials.png" />

#### Configuring credentials in Refold

App settings page lets you configure the authentication settings for an `OAuth2` based application. For your customers to provide you authorization to access their data,
they would first need to install your application. This page lets you set up your application credentials.

<img height="200" src="https://mintcdn.com/cobalt-55/0IGKzTphHY-auv_h/images/Jira/jira_cobalt.png?fit=max&auto=format&n=0IGKzTphHY-auv_h&q=85&s=039feb7417d03d61c123dbebd9183015" alt="Setting up application client credentials" data-path="images/Jira/jira_cobalt.png" />

Refold lets you use pre-configured applications to play around. You can do so by selecting `Use our credentials`. However, if you wish to use your own application,
select `Use your own credentials`. Provide the acquired Client Id and Client secret and click on `Save changes`.

#### Configuring Scopes

Refold lets you configure what permissions to ask from your users while they install your application. The scopes can be added or removed from the App settings page, under `Permissions & Scopes`
section.

For some applications Refold sets mandatory scopes which cannot be removed. Additional scopes can be selected from the drop down. Refold also has the provision to add any
custom scopes supported by the respective platform.

<img height="200" src="https://mintcdn.com/cobalt-55/0IGKzTphHY-auv_h/images/Jira/jira_scopes.png?fit=max&auto=format&n=0IGKzTphHY-auv_h&q=85&s=d38c73d0c96d4982434261943e92c4e6" alt="OAuth Scopes" data-path="images/Jira/jira_scopes.png" />

Once the scopes has been added to the application in Refold, go to your [Jira Developer Portal](https://developer.atlassian.com/console) and update the scopes as added on Refold.

Select the OAuth App created for Refold > Click on `Permissions` in the left menu > Click `Configure` in **Jira API** > Click on `Edit Scopes` > Select the scope > Click on `Save` .

<Warning>
  If you are facing scopes missing or invalid scope error. Make sure you are not passing any custom scope not supported by the platform. And, the scopes selected here are
  identical to the ones selected in the platform.
</Warning>

#### Jira Single Webhook URL

If you wish to create an orchestration where a workflow is being triggered when some operation occurs in Jira, you'd need to subscribe to Jira's Webhook. Refold provides
a single webhook URL to manage such event triggers for all your customers.

**To setup Jira webhook subscription:**

1. Select **Jira** from the application list in **Refold**, and select `Settings`.
2. Copy the `Single Webhook Url`.
3. In your **Jira Admin account**, click on `Gear` icon in the top right > Select `System` under Jira Settings.

<img height="200" src="https://mintcdn.com/cobalt-55/0IGKzTphHY-auv_h/images/Jira/jira_system.png?fit=max&auto=format&n=0IGKzTphHY-auv_h&q=85&s=5b76487814ce69527e23cebeda84df5d" alt="Jira Webhooks Registration" data-path="images/Jira/jira_system.png" />

4. Scroll down in the side menu and select `WebHooks`.

5. Click on `+ Create a WebHook`, give it a `Name`, paste the Webhook URL that you copied under `URL` and add relevant events for which you want to be notified.

<Note>
  Make sure the WebHook created has the **Enabled** status.
</Note>

<img height="200" src="https://mintcdn.com/cobalt-55/0IGKzTphHY-auv_h/images/Jira/jira-url.png?fit=max&auto=format&n=0IGKzTphHY-auv_h&q=85&s=81702c5d2f7faa8b918c8c0abf215d11" alt="Setting up Jira WebHook URL" data-path="images/Jira/jira-url.png" />
