Jes*_*lam 5 asp.net oauth owin katana
我从Visual Studio 2013获得了一个近乎完整的ASP.NET MVC模板应用程序.它是使用以下设置创建的:
创建>项目> Web> ASP.NET Web应用程序>确定> MVC,个人用户帐户>确定
我正在尝试使用OWIN Google提供商登录并遇到问题.
OWINs Configuration方法如下所示:
app.UseCookieAuthentication(new CookieAuthenticationOptions
{
AuthenticationType = DefaultAuthenticationTypes.ApplicationCookie,
LoginPath = new PathString("/Account/Login")
});
app.UseExternalSignInCookie(DefaultAuthenticationTypes.ExternalCookie);
var google = new Microsoft.Owin.Security.Google.GoogleOAuth2AuthenticationOptions
{
ClientId = "xxxxx.apps.googleusercontent.com",
ClientSecret = "xxxxxxxxx-yyyyyyyyy"
};
google.Scope.Add("profile");
google.Scope.Add("email");
app.UseGoogleAuthentication(google);
Run Code Online (Sandbox Code Playgroud)
我点击Google网页上的提供商按钮,通过谷歌进行身份验证,然后返回参考ExternalLoginCallback.此时,该过程在此行中出现故障:
var loginInfo = await AuthenticationManager.GetExternalLoginInfoAsync();
loginInfo是null,它将我重定向回登录页面,没有任何可见的错误.
小智 5
我在这里回答的是一个老问题,但对于以后可能遇到此问题的任何人,对我有用的解决方案是使用Google Developers Console中的API Manager启用“ Google+ API”。
| 归档时间: |
|
| 查看次数: |
807 次 |
| 最近记录: |