Generating a JWT Authentication Token for Zephyr Squad Cloud API
This page explains how to generate a JWT authentication token that is required to make requests to Zephyr Squad REST API.
Prerequisites
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.
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
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
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
Create a folder and the run the
git clone https://github.com/zephyrdeveloper/zapi-cloud.git
from the command prompt to download the project.Afterwards, import the project into Eclipse (or anything similar).
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:
zfj-cloud-rest-client-1.2-jar-with-dependencies.jar
Right click on the Project(s), select Build Path, and then select Configure Build Path.
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:
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
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.
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.
Enable Authorization and then provide the JWT token that you generated from the previous section.
JWT Token: Generated from Eclipse above.
Enable zapiAccessKey and then provide the access key that you generated from the previous section.
Access Key: Retrieved from the pre-requisites above.
Enter the contents for the body of the Postman API call.
Afterwards, click on Send to execute the API call: