# How to generate JWT or get shared secret in front-end to access my own REST API server using Atlassian Spring Boot starter?

**URL:** <https://community.developer.atlassian.com/t/how-to-generate-jwt-or-get-shared-secret-in-front-end-to-access-my-own-rest-api-server-using-atlassian-spring-boot-starter/50493>\
**Category:** Jira Cloud\
**Tags:** auth, ac-spring-boot, jwt, security, jira-cloud, rest-api\
**Created:** [July 30, 2021, 3:49pm UTC](https://community.developer.atlassian.com/t/how-to-generate-jwt-or-get-shared-secret-in-front-end-to-access-my-own-rest-api-server-using-atlassian-spring-boot-starter/50493 "2021-07-30T15:49:53Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![ShenbagaMurugan](https://avatars.discourse-cdn.com/v4/letter/s/bb73d2/32.png) [@ShenbagaMurugan](https://community.developer.atlassian.com/u/ShenbagaMurugan)\
**Post date:** [July 30, 2021, 3:49pm UTC](https://community.developer.atlassian.com/t/how-to-generate-jwt-or-get-shared-secret-in-front-end-to-access-my-own-rest-api-server-using-atlassian-spring-boot-starter/50493/1 "2021-07-30T15:49:54Z")

</div>

Hi,

I have developed some REST APIs and deployed it in my server (say `mysite.com`)

I have used Spring boot and Atlassian connect starter. Hence I am able to leverage the Spring security (@AuthenticationPrincipal AtlassianHostUser). And I have created the UI for my connect app using some JS framework. My UI is loaded as expected in the iframe as configured in the `atlassian-connect.json`. But I can access my REST API only if I have @IgnoreJwt is given. Else JWT token validation fails.

To overcome this, I have to generate the JWT token from the front-end so that the request is accepted by my REST server. Is there any Atlassian provided library or built-in function to generate a JWT signed request to my server?

If not, is there a way to access the “sharedSecret” in my UI code so that I can generate the JWT token?

Finally, if both of the above are not possible, how should I send the sharedSecret to the UI from my REST server (which is persisted in the atlassian\_host table automatically)?

---

<div class="post-metadata">

**Author:** ![richard.white](https://sea1.discourse-cdn.com/atlassiandeveloper/user_avatar/community.developer.atlassian.com/richard.white/32/38845_2.png) [@richard.white](https://community.developer.atlassian.com/u/richard.white)\
**Post date:** [July 30, 2021, 8:27pm UTC](https://community.developer.atlassian.com/t/how-to-generate-jwt-or-get-shared-secret-in-front-end-to-access-my-own-rest-api-server-using-atlassian-spring-boot-starter/50493/2 "2021-07-30T20:27:26Z")

</div>

Hi,

Atlassian provide a JS method for this purpose:  
[https://developer.atlassian.com/cloud/jira/platform/jsapi/context/](https://developer.atlassian.com/cloud/jira/platform/jsapi/context/)

This retrieves a JWT token, known as a context JWT, which you can use to authenticate as the current user, back to your server.

Then in your server endpoint, I believe you just need to annotate with `@ContextJWT`
