Generating a JWT Authentication Token for Zephyr for Jira Cloud API

Zephyr for Jira is now Zephyr Squad! Read more about this.

Zephyr for Jira is now Zephyr Squad! Read more about this.

This page explains how to generate a JWT authentication token that is required to make requests to Zephyr for Jira Cloud REST API.

Prerequisites

1. Generate an access and secret key.

  • Navigate to any project in Jira.

  • Navigate to the Zephyr section and click on “API keys” option.

  • Click on the Generate button and then copy both the access and secret key.

2. Get the AccountID for the user that is going to be authenticating.

  • The easiest way to retrieve the AccountID is to click on the icon on the left-hand menu and then click the Profile link. Within the URL, you can find your AccountID after the last “/”.

    • Example: https://********.atlassian.net/people/5bb7ad0ccc53fd0760103780

  • Another way to get your AccountID is to utilize the following URL in your browser.

    • AccountID for yourself: https://********.atlassian.net/people/rest/api/3/myself

    • AccountID for all users: https://********.atlassian.net//rest/api/3/users/search

3. Get the zephyrBaseURL (end point) for your instance.

  • Example: https://prod-api.zephyr4jiracloud.com/connect/

Once all the above information is generated and gathered, you can provide the details in the code and generate the JWT token using the steps in the next section.

Generate a JWT token

1. Navigate to your GitHub URL and clone the project to your local machine.

  • Example: https://github.com/zephyrdeveloper/zapi-cloud/tree/master/Samples/src/com/thed/zapi/cloud/sample

2. Create a folder and the run the “git clone https://github.com/zephyrdeveloper/zapi-cloud.git” from the command prompt to download the project.

3. Afterwards, import the project into Eclipse (or anything similar).

4. Once the project is configured in Eclipse, download the far file from the link below and add it to your project.

  • This jar file is used to generate the JWT authentication for the APIs.

5. Right click on the Project(s), select Build Path, and then select Configure Build Path.

6. Select the Libraries tab, and then click on the Add External Jars button. Select and add the jar file that was just downloaded. Afterwards, click Apply and close.

7. Navigate to the sampleJwtGenerate.java file to generate the JWT token.

  • Example file path: zapi-cloud/Samples/src/com/thed/zapi/cloud/sample/sampleJwtGenerator.java

8. Fill in the information for the zephyrBase URL, accessKey, secretKey, accountID within the code for the java file and then run it to generate your JWT token.

How to use the JWT token and execute an API call in Postman

Provide the details in the Postman call.

1. Setup the API Call by change the type of API method and by providing the API URL.

  • Change the API Method to POST.

  • Add in the API URL for the specific API Call.

2. Enable Authorization and then provide the JWT token that you generated from the previous section.

  • JWT Token: Generated from Eclipse above.

3. Enable zapiAccessKey and then provide the access key that you generated from the previous section.

  • Access Key: Retrieved from the pre-requisites above.

4. Enter the contents for the body of the Postman API call.

5. Afterwards, click on send to execute the API call.