简体   繁体   English

Android OAUTH:刷新我的令牌

[英]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.

相关问题 OAuth令牌类型和刷新 - OAuth token types and refreshing "在 Android 中使用 Retrofit2 \/ Kotlin 成功刷新 Oauth 2 令牌后出现 400 错误" - 400 error after successfully refreshing Oauth 2 Token using Retrofit2 / Kotlin in Android Firebase onNewToken 不刷新我的令牌 - Firebase onNewToken not refreshing my token 使用 Retrofit 刷新 OAuth 令牌而不修改所有调用 - Refreshing OAuth token using Retrofit without modifying all calls 在Android上保存foursquare oauth令牌 - save foursquare oauth token on Android 如何获得 android OAuth 的令牌? - How to get token for android OAuth? Android-根据什么Firebase刷新令牌 - Android - According to what Firebase refreshing token 为什么我的Android SwipeRefreshLayout无法刷新? - Why is my Android SwipeRefreshLayout not refreshing? 我的Android客户端中的Google Cloud Endpoint身份验证:不允许受众,并且Oauth框架用户与oauth令牌用户不匹配 - Google Cloud Endpoint Authentication from my Android Client: Audience not Allowed and Oauth framework user didn't match oauth token user 在Android上的我的应用之间共享oauth令牌-共享的用户ID,钥匙串,AccountManager或其他? - Sharing oauth token between my apps on Android - Shared User ID, Keychain, AccountManager or something else?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM