ios - 0Auth2: when do you use the refresh token to get a new access token? Before or after it expires? -


i'm developing api used ios app , curious on best practice using refresh token in oauth2. using user password grant generate access token , refresh token.

if token expires every 60 minutes means every 60 minutes client have make 3 consecutive api calls: 1. use access token resource api, 2. api responds invalid token need use refresh token, 3. token refreshed need try initial call again.

so, wanting know if it's best refresh token before expires? or better generate new access token once api has responded expired token error?

not sure there's best practice such, it's more efficient refresh in advance won't make requests can know fail. cost of timer refresh less cost of network communication.

you still need handling token being invalid on request server invalidate token number of other reasons, 'how can make efficient , user friendly' 'can remove of code' kind of thing. handling error response standard, refreshing in advance user friendly.

be cautious refreshing while have in-flight requests , inadvertently cause request fail invalidating token...


Comments

Popular posts from this blog

Magento/PHP - Get phones on all members in a customer group -

php - .htaccess mod_rewrite for dynamic url which has domain names -

Website Login Issue developed in magento -