Ken.N
Ken.N

Reputation: 157

Whenever use Refresh token In Web API?

I have a web API in Server, and MVC in Client.

I issues access token with 30 minutes. How to khow whenever i need refresh token ?

Upvotes: 0

Views: 1337

Answers (1)

Andrei Dragotoniu
Andrei Dragotoniu

Reputation: 6335

each access token is valid for a certain amount of time. When you request a token, you will get a bit more information not just the token itself, for example how long the token is valid for ( in seconds ) and also the expiration time itself.

You could store that somewhere and before you issue another call just check if the expiration time has passed. If it did then simply request another token or refresh the one you already have.

I have an article on this subject as well, it doesn't do refresh but it explains everything enough so you should be able to understand how to use it properly:

https://eidand.com/2015/03/28/authorization-system-with-owin-web-api-json-web-tokens/

Upvotes: 1

Related Questions