SimpleTokenProvider icon indicating copy to clipboard operation
SimpleTokenProvider copied to clipboard

Refresh tokens and keeping tokens alive

Open jomargon opened this issue 9 years ago • 11 comments

What is the best way to implement refresh tokens using this approach? Thanks in advance.

jomargon avatar Nov 20 '16 21:11 jomargon

I added a sample for generating refreshed tokens in #16

MihaMarkic avatar Dec 02 '16 09:12 MihaMarkic

i am new in token. can i ask a question? when will i send a request to RefreshPath?

anhlee24 avatar Jan 11 '17 10:01 anhlee24

@anhlee24 That's up to you. You can calculate it by adding expiration time to current time.

MihaMarkic avatar Jan 11 '17 10:01 MihaMarkic

@MihaMarkic you mean that if i set the expiration time by 30m. So i will setup the Client (SPA) to send a request to RefreshPath to keep it alive after 30m?

anhlee24 avatar Jan 11 '17 11:01 anhlee24

@anhlee24 Yes, but more likely slightly before expiration, like after 29m or something :)

MihaMarkic avatar Jan 11 '17 11:01 MihaMarkic

Thank you so much!

anhlee24 avatar Jan 11 '17 12:01 anhlee24

@MihaMarkic Hi, I want to handle the acccess_token expiraton at server side, how can i handle it?

The response header contain: "Bearer error="invalid_token", error_description="The token is expired", but i don't know how to handle this error. Can you give me any suggest? Thank you :)

anhlee24 avatar Jan 12 '17 08:01 anhlee24

@anhlee24 Could it be that your token has actually expired? You have to request the refresh before it expires.

MihaMarkic avatar Jan 12 '17 08:01 MihaMarkic

@MihaMarkic Yes. But i want to handle the token expiration in Client (SPA) to redirect to Login page or Unauthorized page, etc ...

anhlee24 avatar Jan 12 '17 09:01 anhlee24

@anhlee24 On client side you should catch Unauthorized response after each request and redirect app to login page somehow. This is really up to the client implementation.

MihaMarkic avatar Jan 12 '17 10:01 MihaMarkic

@MihaMarkic Thank you so much :).

anhlee24 avatar Jan 12 '17 10:01 anhlee24