Contributions
- 1.9KViews1like0Comments
Re: JWT generation
Hi, thanks. I had the decode function, but I don't know if don't have the right jwt library, because when using it I get this error: token = jwt.encode(payload_token, SECRET_KEY, algorithm='HS256').strip().decode('utf-8') AttributeError: 'str' object has no attribute 'decode'1.9KViews0likes2CommentsJWT generation
I am trying to generate a JWT using python. I followed the given example in the documentation, but I always get error 400. I am using the following code: # BASE URL for Zephyr for Jira Cloud BASE_URL = 'https://prod-api.zephyr4jiracloud.com/connect' # RELATIVE PATH for token generation and make request to api RELATIVE_PATH = '/public/rest/api/1.0/cycle' # CANONICAL PATH (Http Method & Relative Path & Query String) CANONICAL_PATH = 'POST&'+RELATIVE_PATH+'&' # TOKEN HEADER: to generate jwt token payload_token = { 'sub': ACCOUNT_ID, 'qsh': hashlib.sha256(CANONICAL_PATH.encode('utf-8')).hexdigest(), 'iss': ACCESS_KEY, 'exp': int(time.time())+JWT_EXPIRE, 'iat': int(time.time()) } # GENERATE TOKEN token = jwt.encode(payload_token, SECRET_KEY, algorithm='HS256').strip() headers = { 'Content-Type': 'application/json', 'Authorization': 'JWT '+token, 'zapiAccessKey': ACCESS_KEY } # REQUEST PAYLOAD: to create cycle cycle = { 'name': 'Sample Cycle', 'projectId': '10200', 'versionId': '5.X' } raw_result = requests.post(BASE_URL + RELATIVE_PATH, headers=headers, json=cycle) Could anyone tell me what I'm doing wrong?2KViews0likes4Comments