There is a general use-case in any application that the authentication token expires, and you need to refresh the internally. After upgrading the t...
For further actions, you may consider blocking this person and/or reporting abuse
Many folks requested me to write a good implementation of
TokenAuthenticator
class i.e. how to refresh token.Soon I will publish a new article on how I refresh tokens in authenticator.
if requestParams potentially consists of username and password, how do you provide that on the fly especially when the primary functionality of the app is to log the user out to the login activity when token is expired. By the way, this technique surely informs about 401 code.
Ideally we should have a refreshToken() function instead of login again.
But if you want to login again, then you can display a modal to user to enter username and password then resume this functionality as per given in blog.
nice article, i think i should use this in my next project 😁
Thanks Adri. Sure we should use this.
Can I use this solution for parallel request API?
Ofcourse. Make sure you manage
authenticate()
method accordingly.E.g. make
getUpdatedToken()
call synchronizeAwesome, thank you very much!!!!!!!
i need this for my work.
You saved me.
Thanks @ricardo
If refresh token is expired also, and request refresh token return 401, how to handle this case?
Here is the complete code which I used in one project: