Generating a JWT Authentication Token for Zephyr Squad Cloud API

Applies to Zephyr Squad Cloud, last modified on January 13, 2022

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

Prerequisites

  1. Generate an access and secret key.

    • Navigate to any project in Jira.

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

    • Click 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.

  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:

    Add External JARs to the project

    Click the image to enlarge it.

  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

    The sampleJwtGenerate class

    Click the image to enlarge it.

  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.

    The sampleJwtGenerate example

    Click the image to enlarge it.

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:

    Call API in Postman

    Click the image to enlarge it.

See Also

Zephyr Squad Cloud REST API

Highlight search results