[英]Android OAUTH: Refreshing my token
In my Android application, I'm using OAUTH to authenticate with a service. 在我的Android应用程序中,我使用OAUTH对服务进行身份验证。 When I authenticate I get an access_token and a refresh_token; 当我进行身份验证时,我得到一个access_token和refresh_token; pretty standard. 很标准。
The access token expire every hour, and you need to use your refresh token to get a new access token. 访问令牌每小时都会过期,因此您需要使用刷新令牌来获取新的访问令牌。 Should I have a service that runs once an hour to refresh that for the user - or is it acceptable to have refresh token call every time I make a call to the server? 我应该有一个每小时运行一次的服务来为用户刷新该服务吗?还是每次我对服务器进行呼叫时都具有刷新令牌调用是可以接受的? I know it would have more network usage for the user for the latter case, but we're talking negligible amounts of data even for 50 token refreshes. 我知道在后一种情况下,它将为用户带来更多的网络使用率,但即使是50次令牌刷新,我们谈论的数据量也微不足道。
Thanks for any advice! 感谢您的任何建议!
You can have a service which runs every 50 mins to refresh your token or whenever you receive invalid token, token expired response you can refresh the token. 您可以使用每50分钟运行一次的服务来刷新令牌,或者每当收到无效令牌,令牌过期响应时,您都可以刷新令牌。 I would prefer 50min refresh, that way you don't have to hit the OAuth server for tokens for every request. 我希望刷新50分钟,这样您就不必为每个请求都在OAuth服务器上获取令牌。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.