我在使用以下博客文章中的信息时遇到问题
https://cgillum.tech/2016/03/07/app-service-token-store/
我有一个可以使用 Windows 或 Google 帐户登录的应用。
使用 Windows 帐户一切都很好。
我能够登录并接收刷新 token 。
这将毫无问题地刷新。
使用 Google 帐户,我不会获得刷新 token ,并且 Google 帐户不会请求我的许可来拥有离线范围。
这是我用来登录的代码:
return await client.LoginAsync(myView, MobileServiceAuthenticationProvider.Google, new Dictionary<string, string>() {
{ "access_type", "offline" } });
最佳答案
我认为问题可能是什么(来自 Google 的 OAuth documentation):
Important: When your application receives a refresh token, it is important to store that refresh token for future use. If your application loses the refresh token, it will have to re-prompt the user for consent before obtaining another refresh token. If you need to re-prompt the user for consent, include the prompt parameter in the authorization code request, and set the value to consent.
基本上,如果您已经收到特定请求的刷新 token ,听起来 Google 不会给您新的 token ,除非您明确提示用户同意离线范围。您可以通过在登录中添加 prompt=consent 查询字符串参数来完成此操作。例如:
/.auth/login/google?access_type=offline&prompt=consent
我见过其他人也这么做过。尝试一下,看看是否也能解决您的问题。
关于android - 如何使用 Azure 应用服务让 Google 帐户显示离线范围,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36305826/