Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

You can use this pseudocode to generate a JWT token:

Code Block
// A function to build Query String Hash
// See: https://developer.atlassian.com/cloud/jira/platform/understanding-jwt/#qsh
function QSH(url)
  retrun qsh_of_url
 
// Use a JWT library  to encode and sign the claim
import JWTEncode from JWT

// Declare the ZAPI access key, secret key and the account Id
zapi_access_key = your Zapi access key
zapi_secret_key = your Zapi secret key
account_id = your account id

// Declare Zephyr results API URL
api_url = https://prod-api.zephyr4jiracloud.com/connect/public/rest/api/1.0/bdd/results/import

// Build Query String Hash of the API URL
api_url_qsh = QSH(api_url)

// Build your JWT claim
claim = a hashmap with the following
  iss: zapi_access_key,
  iat: NumericDate of now,
  exp: NumericDate of now + 1 minute,
  qsh: api_url_qsh,
  sub: account_id
  
  
// Encode and sign your claim
token = JWTEncode(claim, zapi_secret_key)

// Print token or use it to set the Authorization header
print token

More information on how to generate JWT tokens can be found here.

...