I am getting “401 Unauthorized” when trying to make REST API Call with JWT Token which was generated using context exchange information during Connect App installation.
Here my code . I tried every possible way but still it seems like i’m missing something.
I am using “atlassian-jwt” package to generate token
function GetToken(){
const now = moment().utc();
const request = jwt.fromMethodAndUrl('GET', '/rest/api/3/issue');
const tokenData = {
"iss": 'com.example.myapp',
"aud":"{clientKey}",
"iat": now.unix(),
"exp": now.add(3, 'minutes').unix(),
"qsh": jwt.createQueryStringHash(request)
};
const secret = '{Shared_Secret_From_installation_context}';
const token = jwt.encodeSymmetric(tokenData, secret);
return token
}
Can you guys help me out where I’m doing wrong or missing something?
My Connect App Descriptor has Scope [“READ”,“WRITE”,“ACT_AS_USER”]