# Cakephp 3.6.x: JWT/Admad refresh token raised exception

**URL:** <https://discourse.cakephp.org/t/cakephp-3-6-x-jwt-admad-refresh-token-raised-exception/4662>\
**Category:** Need Help\
**Created:** [August 3, 2018, 2:12pm UTC](https://discourse.cakephp.org/t/cakephp-3-6-x-jwt-admad-refresh-token-raised-exception/4662 "2018-08-03T14:12:40Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![Speudyland](https://yyz1.discourse-cdn.com/flex029/user_avatar/discourse.cakephp.org/speudyland/32/569_2.png) [@Speudyland](https://discourse.cakephp.org/u/Speudyland)\
**Post date:** [August 3, 2018, 2:12pm UTC](https://discourse.cakephp.org/t/cakephp-3-6-x-jwt-admad-refresh-token-raised-exception/4662/1 "2018-08-03T14:12:40Z")

</div>

Hi,

I’m developed an API with cake by using REST. From m app, I authenticate user with a json web token by using the plugin JWT/ADmad.

Everything works fine if I log in and log out. But when I need to refresh the token, it’s not working. An exception is raised as “expired token”. I found no way to debug or to intercept the expired token and be able to refresh the token.

I tried by using two tokens as mentioned but even if I send the refresh token to check if it’s still valid from cake, it raised an exception: Expired token.

I can do nothing more, no debbug, no error log, … except Expired token. I checked the plugin code the exception should right. Does someone got this issue before ?

So I’m wondering how to refresh the token if this one is expired…I don’t find any example, so if someone have an idea on how to solve this with cake ?

Thanks 😉

---

<div class="post-metadata">

**Author:** ![ADmad](https://yyz1.discourse-cdn.com/flex029/user_avatar/discourse.cakephp.org/admad/32/20_2.png) [@ADmad](https://discourse.cakephp.org/u/ADmad)\
**Post date:** [August 6, 2018, 5:18pm UTC](https://discourse.cakephp.org/t/cakephp-3-6-x-jwt-admad-refresh-token-raised-exception/4662/2 "2018-08-06T17:18:11Z")

</div>

Once a token expires nothing can be done. You aren’t supposed to intercept it.

The plugin itself has no mechanism for token refresh.

So either use single lived tokens and when it expires make the client send request for new token by submitting his login/password again.

If you are using 2 tokens then instead of login/password the client would submit it’s long lived token for authentication.

---

<div class="post-metadata">

**Author:** ![Speudyland](https://yyz1.discourse-cdn.com/flex029/user_avatar/discourse.cakephp.org/speudyland/32/569_2.png) [@Speudyland](https://discourse.cakephp.org/u/Speudyland)\
**Post date:** [August 7, 2018, 6:20am UTC](https://discourse.cakephp.org/t/cakephp-3-6-x-jwt-admad-refresh-token-raised-exception/4662/3 "2018-08-07T06:20:59Z")

</div>

Thanks @ADmad. Oki, you confirm my last thoughts…

Let’s check the way with a refresh token. 😉

---

<div class="post-metadata">

**Author:** ![Maniraj](https://avatars.discourse-cdn.com/v4/letter/m/51bf81/32.png) [@Maniraj](https://discourse.cakephp.org/u/Maniraj)\
**Post date:** [June 30, 2020, 10:48am UTC](https://discourse.cakephp.org/t/cakephp-3-6-x-jwt-admad-refresh-token-raised-exception/4662/4 "2020-06-30T10:48:19Z")

</div>

Hi,

I have implemented admad JWT plugin. I’m facing problem to customise API url  
I have this URL : [http://localhost/api/users/token.json](http://localhost/api/users/token.json)

wants to change above url to this url : [http://localhost/api/token](http://localhost/api/token)  
I also tried [http://localhost/api/users/token](http://localhost/api/users/token)  
It gives me an error that “the requested address  
**‘/api/users/token’** was not found on this server.”

How can I customise this?

---

<div class="post-metadata">

**Author:** ![Zuluru](https://yyz1.discourse-cdn.com/flex029/user_avatar/discourse.cakephp.org/zuluru/32/1230_2.png) [@Zuluru](https://discourse.cakephp.org/u/Zuluru)\
**Post date:** [June 30, 2020, 3:07pm UTC](https://discourse.cakephp.org/t/cakephp-3-6-x-jwt-admad-refresh-token-raised-exception/4662/5 "2020-06-30T15:07:22Z")

</div>

What, specifically, did you do to try what you tried?
