Not able to authenticate with API Key
I am expecting authentication process to zephyr squad public api server, tried with Java or Typescript still getting unauthorized error. Do we need JWT or API access key can help in authentication
TypeScript code used for JWT
import { chromium } from 'playwright';
import jwt from 'jsonwebtoken';
import * as fs from 'fs';
import * as path from 'path';
async function generateJwt() {
// Replace Zephyr BaseUrl with the <ZAPI_CLOUD_URL> shared with ZAPI Cloud Installation
const zephyrBaseUrl = '<ZAPI_CLOUD_URL>';
// zephyr accessKey and secretKey, obtained from Addons >> zapi section
const accessKey = 'YjE2MjdjMGEtNzExNy0zYjY1LWFkMzQtNjcwMDM3IGI0NjI3YzBhLTUxMTctMzM2NS1hZDM0IGFkbWlu';
const secretKey = 'qufnbimi96Ob2hq3ISF08yZ8nUvDRHmQwHGeGlk';
const accountId = 'accountId'; // Jira accountId
// Create a JWT token
const expirationInSec = 360; // Token expiration time in seconds
const createCycleUri = `${zephyrBaseUrl}/public/rest/api/1.0/cycle?expand=&clonedCycleId=`;
const payload = {
// JWT payload can include any required data
accountId,
uri: createCycleUri,
};
const token = jwt.sign(payload, secretKey, { expiresIn: expirationInSec });
// Print the URL and JWT token to be used for making the REST call
console.log('FINAL API : ' + createCycleUri);
console.log('JWT Token : ' + token);
}
// Run the function
generateJwt().catch(err => console.error('Error generating JWT:', err));
New contributor
user47910 is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.