# Setup

> To connect to Jira using this activity package, you must first create the credentials required by the [Jira Scope](https://docs.uipath.com/activities/other/latest/legacy-integrations/jira-scope) to authenticate all subsequent calls. The scope currently supports two types of authentication:

## Introduction

To connect to Jira using this activity package, you must first create the credentials required by the [Jira Scope](https://docs.uipath.com/activities/other/latest/legacy-integrations/jira-scope) to authenticate all subsequent calls. The scope currently supports two types of authentication:

* **API Token**: An authentication token is generated by Jira for your user. This method supports fully unattended automations.
* **OAuth 2.0**: A client ID and secret are generated by Jira and may be used for all users within an organization. This method displays, at runtime, a login screen in which a user may enter their login credentials for Jira or any of its SSO providers. A token is produced and saved locally. This token is short-lived and may have to be refreshed at a later time. For this reason, this method supports attended and some unattended automations.

Please follow the steps below to prepare a set of credentials for your activities.

## Credentials

### Option 1: API Token

1. Follow [Atlassian's instructions here](https://confluence.atlassian.com/cloud/api-tokens-938839638.html) to generate an API token.
2. Add a Jira Scope to your workflow and change the **Authentication Type** parameter to `Api Token`.
3. Fill in the **Server URL** property with the URL of your organization's Jira instance. For Cloud instances, this is usually in the form of `https://<your org>.atlassian.net`.
4. Lastly, fill in the **Api Token** property with the token generated in step 1 and the **Username** property with the email you use to log into the designated Jira instance. The Jira Scope is now ready for use.

### Option 2: OAuth 2.0

1. Follow [Atlassian's instructions here on Enabling OAuth 2.0 (3LO)](https://developer.atlassian.com/cloud/jira/platform/oauth-2-authorization-code-grants-3lo-for-apps/#enabling-oauth-2-0--3lo-) create a new "app".

   ![docs image](https://dev-assets.cms.uipath.com/assets/images/activities/legacy-integrations-docs-image-180684-67b4f398-6b819c64.webp)
2. Under **APIS AND FEATURES**, select **OAuth 2.0 (3LO)**. Enter `http://127.0.0.1:10001/authorize/` in the **Callback URL** field. This instructs the Jira app to return to the machine running the activities once it has finished authenticating a user.

   ![docs image](https://dev-assets.cms.uipath.com/assets/images/activities/legacy-integrations-docs-image-183697-768da76e-1df23e82.webp)
3. Under **APIS AND FEATURES** and select **Add** to give the app access to Atlassian APIs. Select the **Add** button under **Jira platform REST API**.

   ![docs image](https://dev-assets.cms.uipath.com/assets/images/activities/legacy-integrations-docs-image-179080-c6ce3edd-56183167.webp)
4. The **Add** button will be replaced with one that says **Configure**. Click this to choose the permissions given to the app. Add `read:jira-work`, `manage:jira-project`, `manage:jira-configuration`, `read:jira-user`, and `write:jira-work`.

   ![docs image](https://dev-assets.cms.uipath.com/assets/images/activities/legacy-integrations-docs-image-180456-4e196f33-e6717acf.webp)

   ![docs image](https://dev-assets.cms.uipath.com/assets/images/activities/legacy-integrations-docs-image-183425-bef9bf73-cc84662a.webp)
5. Navigate back to **App Details** and copy your Client ID and Secret. These may now be used in a workflow.

   ![docs image](https://dev-assets.cms.uipath.com/assets/images/activities/legacy-integrations-docs-image-178195-ebeb71dd-c9f269ff.webp)
6. Add a Jira Scope to your workflow and change the **Authentication Type** parameter to `OAuth 2.0`.
7. Fill in the **Server URL** property with the URL of your organization's Jira instance. For Cloud instances, this is usually in the form of `https://<your org>.atlassian.net`.
8. Lastly, fill in the **Client ID** and **Client Secret** properties with the values copied in step 5. The Jira Scope is now ready for use. To transform the variable type from String to SecureString, in the default parameter for the **clientSecret**, you can use this command: `(new System.Net.NetworkCredential("","*YOUR_SECRET*")).SecurePassword`

   ![docs image](https://dev-assets.cms.uipath.com/assets/images/activities/legacy-integrations-docs-image-182869-ca5e17da-5037adee.webp)
9. If you follow the above steps in Studio and you receive the `RemoteException wrapping System.Net.HttpListenerException: The network location cannot be reached. For information about network troubleshooting, see Windows Help` error message when trying to execute the Jira Scope, the solution is to open a **cmd.exe** as Administrator and run this command:

   `netsh http add iplisten ipaddress=127.0.0.1`

   ![docs image](https://dev-assets.cms.uipath.com/assets/images/activities/legacy-integrations-docs-image-181060-ab5837a8-e8d50274.webp)
10. After the first execution of the Jira Scope, you receive an authorization request window in your default browser where you need to specify the Jira site and then click **Accept**.

    ![docs image](https://dev-assets.cms.uipath.com/assets/images/activities/legacy-integrations-docs-image-181072-b7218da6-41558a24.webp)
