【发布时间】:2014-09-23 14:44:46
【问题描述】:
我正在使用谷歌的中间件进行身份验证
以下是我的中间件设置
app.UseCookieAuthentication(new CookieAuthenticationOptions
{
//AuthenticationType = AuthServerConstants.PrimaryAuthenticationType
AuthenticationMode = AuthenticationMode.Passive,
AuthenticationType = DefaultAuthenticationTypes.ExternalCookie,
ExpireTimeSpan = TimeSpan.FromMinutes(30)
}).UseExternalSignInCookie(AuthServerConstants.ExternalAuthenticationType);
以下是我的谷歌中间件
var google = new GoogleOAuth2AuthenticationOptions
{
ClientId = AppSettingHelpers.GetValue<string>(AppSettingConstants.GoogleAppId),
ClientSecret = AppSettingHelpers.GetValue<string>(AppSettingConstants.GoogleAppSecret),
SignInAsAuthenticationType = signInAsType,
AuthenticationMode = AuthenticationMode.Passive
};
app.UseGoogleAuthentication(google);
我已在 google 开发者控制台中启用了 Google+API
我使用的是 Google 中间件 2.1 版。我的谷歌身份验证仍然返回error=access_denied
谁能告诉我在这个过程中可能遗漏了什么。
注意 我的外部身份验证 cookie 中间件尚未在浏览器中设置 cookie。
【问题讨论】:
-
你试过不使用GoogleOAuth2AuthenticationOptions直接调用吗?这意味着,app.UseGoogleAuthentication(AppSettingHelpers.GetValue
(AppSettingConstants.GoogleAppId), AppSettingHelpers.GetValue (AppSettingConstants.GoogleAppSecret)) -
还没有,也许我会试试。 v2.1 的正确源代码甚至无法调试。这段代码对我来说工作正常,直到 10 天,突然不知道出了什么问题
-
我是否应该从现在开始迁移到 v3.0 blogs.msdn.com/b/webdev/archive/2014/07/02/…
-
已将所有 OWIN dll 迁移到 3.0.0 版,但问题仍然存在
-
您将它们称为 AppId 和 AppSecret 让我想知道您是否从正确的位置获取这些值。请参阅console.developers.google.com/project/[project]/apiui/…,“Web 应用程序的客户端 ID”
标签: asp.net-mvc-5 owin google-authentication