The Atlassian Community Forums are currently in read-only mode. We will be relaunching on a new platform on September 22 (read more here). We apologize for the extended downtime. For concerns or questions, please email communitymanagers@atlassian.com. See you on the other side, on the new Atlassian Community Forums! :)

×

Forums

Articles
Create
cancel
Showing results forĀ 
Search instead forĀ 
Did you mean:Ā 

What's Wrong With My Token Generation.

Saikat Samanta
I'm New Here
I'm New Here
Those new to the Atlassian Community have posted less than three times. Give them a warm welcome!
March 29, 2021

What's wrong with my JWT generation I am using this code to generate JWTScreenshot 2021-03-29 at 9.47.35 PM.png

const jwt = require('atlassian-jwt');

const moment = require('moment');

const now = moment().utc();

const clientKey='XXXXXXXXXXXX';

const sharedSecret = 'XXXXXXXXXXXXXX';

const req = jwt.fromMethodAndUrl('GET', 'https://api.bitbucket.com/2.0/repositories/{bfd8fa1a-XXX-XXX-XXX-XXXXXXX}');

const tokenData = {

"iss": 'codelock',

"iat": now.unix(),

"exp": now.add(30, 'minutes').unix(),

"qsh": jwt.createQueryStringHash(req),

"sub": clientKey

};

const token = jwt.encode(tokenData, sharedSecret);console.log(token);

1 answer

1 accepted

Comments for this post are closed

Community moderators have prevented the ability to post new answers.

1 vote
Answer accepted
Dario B
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
April 6, 2021

Hello @Saikat Samanta ,

Welcome to the Atlassian Community!

I might not be the best person to answer development related questions, however, looking at your screenshot I can see that you are providing a wrong authorization header.

Indeed, in your screenshot I can see:

Authorization: JWT <token>

 

While it is supposed to be:

Authorization: Bearer <token>

 

Therefore, there are chances there is nothing wrong with the code to generate the JWT token and that the issue is just with the authorization header you are providing.

 

Can you kindly try to use the correct header and check if this works?

 

Finally, for the future, please notice that this is not the best place to get help on development  related questions. The right resources are listed in https://developer.atlassian.com/resources. 

Specifically:

 

 

Cheers,
Dario

DEPLOYMENT TYPE
CLOUD
TAGS
AUG Leaders

Atlassian Community Events