AP.context.getToken() doesn't work for jiraDashboardItems modules

AP.context.getToken() works fine in the web-panel or web-page context so that you don’t have to worry about expired JWT token which can be easily refreshed on the client-side.

However it doesn’t work for cloud gadgets - jiraDashboardItems modules.

If you run the below code from the documentation

AP.context.getToken(function(token){
  console.log("JWT token string", token);
});

You will get the below error for the second and all subsequent calls:

POST https://dev.atlassian.net/plugins/servlet/ac/net.brokenbuild.gadget/velocity-gadget 404
ACJS: content resolver failed to get context jwt token

This token refresh feature is super useful and it would be great if it works properly for gadgets too.

Here is the open issue about this reported by another vendor - https://ecosystem.atlassian.net/browse/ACJIRA-1968

Thanks,
Vasiliy

3 Likes

Moreover, it’ll be nice if the AP.context.getToken would not swallow the error so we can do something like AP.context.getToken().then().catch(). Based on the docs, it returns a promise, but the .catch of that promise is never fulfilled.

Ref to the docs https://developer.atlassian.com/cloud/jira/platform/jsapi/ap/

1 Like