我正在使用Microsoft.Owin.Security.Google
(version 3.0.1
) 中间件为我的应用程序提供 Google OAuth。
它是这样配置的:
app.UseGoogleAuthentication(new GoogleOAuth2AuthenticationOptions
{
AuthenticationType = "Google",
Caption = "Google",
SignInAsAuthenticationType = signInAsType, // "idsrv.external"
ClientId = "xxx.apps.googleusercontent.com",
ClientSecret = "xxx"
});
很简单的东西。我使用IdentityServer作为 MW 来发布声明。
当我首次向 Google 验证用户身份时,Google 会征求用户的以下同意:
这完全有道理,因为我openid profile email
在 URL 中请求范围:
https://accounts.google.com/o/oauth2/auth?scope=openid个人资料 email&response_type=code&redirect_uri= https://localhost:44301/core/signin-google&state=xxx&client_id=111.apps.googleusercontent.com&hl=en- GB&from_login=1&as=-25fb4219b2997893&authuser=0
然后我接受,一切正常。
现在,在我注销后,再次重新进行身份验证 - 从现在开始,谷歌一直在询问我“离线访问”:
我没有要求离线访问范围,所以很困惑为什么谷歌要求这个?
确认 URL 看起来不错:
https://accounts.google.com/o/oauth2/auth?scope=openid个人资料 email&response_type=code&redirect_uri= https://localhost:44301/core/signin-google&state=xxx&client_id=111.apps.googleusercontent.com&hl=en- GB&from_login=1&as=676f55265a78c036&authuser=0
所以与第一个请求完全相同的 URL。
我努力了:
- 在 API 控制台中打开 Google+ API
- 尝试添加
&prompt=auto
(导致错误“提示的参数值无效:无效提示:自动”) - 尝试添加
access_type=online
(即使这是默认设置,如果未提供)。 - 尝试添加
approval_prompt=auto
这些技术都没有奏效。
有任何想法吗?