# Atlassian Connect Spring boot JWT expiration

**URL:** <https://community.developer.atlassian.com/t/atlassian-connect-spring-boot-jwt-expiration/56873>\
**Category:** Jira Cloud\
**Tags:** jwt, java, jira-cloud, rest-api\
**Created:** [March 22, 2022, 4:24pm UTC](https://community.developer.atlassian.com/t/atlassian-connect-spring-boot-jwt-expiration/56873 "2022-03-22T16:24:17Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![AmineMekki1](https://avatars.discourse-cdn.com/v4/letter/a/6bbea6/32.png) [@AmineMekki1](https://community.developer.atlassian.com/u/AmineMekki1)\
**Post date:** [March 22, 2022, 4:24pm UTC](https://community.developer.atlassian.com/t/atlassian-connect-spring-boot-jwt-expiration/56873/1 "2022-03-22T16:24:17Z")

</div>

Hello,  
I’m making authenticated requests back to the add-on from within the iframe after a while the next request return JWT expired any solution ? thanks

---

<div class="post-metadata">

**Author:** ![jrichards](https://sea1.discourse-cdn.com/atlassiandeveloper/user_avatar/community.developer.atlassian.com/jrichards/32/39455_2.png) [@jrichards](https://community.developer.atlassian.com/u/jrichards)\
**Post date:** [March 23, 2022, 4:08am UTC](https://community.developer.atlassian.com/t/atlassian-connect-spring-boot-jwt-expiration/56873/2 "2022-03-23T04:08:02Z")

</div>

Hi @AmineMekki1,

Hello and thanks for your question. Maybe some example code might help? JWTs have a timeout, so if you’re saving the token before your loop then you might see this happen, for example if you have

```javascript
let token => AP.context.getToken(token)

```

and then have a loop where you call with fetch() and

```auto
                        headers: {
                            'Authorization': 'JWT ' + token
                        }

```

then yes, the JWT will timeout.

You’ll need to refresh the token.

Regards,  
James.

---

<div class="post-metadata">

**Author:** ![AmineMekki1](https://avatars.discourse-cdn.com/v4/letter/a/6bbea6/32.png) [@AmineMekki1](https://community.developer.atlassian.com/u/AmineMekki1)\
**Post date:** [March 23, 2022, 9:58am UTC](https://community.developer.atlassian.com/t/atlassian-connect-spring-boot-jwt-expiration/56873/3 "2022-03-23T09:58:47Z")

</div>

Hi @jrichards ,  
Thank you for your response, yes i’m using the token like you described so how to refresh it ? and is there another solution ?

Regards,  
Amine

---

<div class="post-metadata">

**Author:** ![jrichards](https://sea1.discourse-cdn.com/atlassiandeveloper/user_avatar/community.developer.atlassian.com/jrichards/32/39455_2.png) [@jrichards](https://community.developer.atlassian.com/u/jrichards)\
**Post date:** [March 23, 2022, 11:52pm UTC](https://community.developer.atlassian.com/t/atlassian-connect-spring-boot-jwt-expiration/56873/4 "2022-03-23T23:52:36Z")

</div>

Hi @AmineMekki1,

Just move the token request into the loop, and request a new one when it fails, or keep a timer associated with it and request a new one when the time is exceeded.

Maybe if you post some example code we can check your design.

Regards,  
James.

---

<div class="post-metadata">

**Author:** ![AmineMekki1](https://avatars.discourse-cdn.com/v4/letter/a/6bbea6/32.png) [@AmineMekki1](https://community.developer.atlassian.com/u/AmineMekki1)\
**Post date:** [March 24, 2022, 10:48am UTC](https://community.developer.atlassian.com/t/atlassian-connect-spring-boot-jwt-expiration/56873/5 "2022-03-24T10:48:22Z")

</div>

Hi, @jrichards ,  
right now i added a timer that get a new token thank you for your help.
