【问题标题】:What should be used instead of UseGoogleAuthentication Method (IAppBuilder)?应该使用什么来代替 UseGoogleAuthentication Method (IAppBuilder)?
【发布时间】:2015-06-25 09:22:48
【问题描述】:

MSDN 文档states

GoogleAuthenticationExtensions.UseGoogleAuthentication 方法 (IAppBuilder)

注意:此 API 现在已过时

还有什么选择?应该用什么来代替这种方法?

【问题讨论】:

  • msdn.microsoft.com/en-us/library/… 可能是 Oauth 的?
  • @DaImTo 是的,应该就是这样。
  • 可能需要考虑 Google .net 客户端库 BTW。我没有打扰过msn的。不过很想听听他们是如何工作的。

标签: c# asp.net asp.net-mvc security oauth


【解决方案1】:

您可以像这样使用 Google OAuth2 中间件:

private void ConfigureAuth(IAppBuilder app)
{
    var cookieOptions = new CookieAuthenticationOptions
    {
        LoginPath = new PathString("/Account/Login")
    };

    app.UseCookieAuthentication(cookieOptions);

    app.SetDefaultSignInAsAuthenticationType(cookieOptions.AuthenticationType);

    app.UseGoogleAuthentication(new GoogleOAuth2AuthenticationOptions
    {
        ClientId = ConfigurationManager.AppSettings["ClientId"],
        ClientSecret = ConfigurationManager.AppSettings["ClientSecret"]
    });
}

您可以在https://console.developers.google.com/ 处创建客户端 ID 和密码

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2010-11-05
    • 2010-12-06
    • 2012-01-16
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多