首页
学习
活动
专区
工具
TVP
发布
社区首页 >问答首页 >获取内部服务器500错误时出现GoogleOauth2问题

获取内部服务器500错误时出现GoogleOauth2问题
EN

Stack Overflow用户
提问于 2014-02-23 12:14:15
回答 5查看 9.1K关注 0票数 19

我决定试一试新的谷歌Oauth2中间件,它几乎打破了一切。这是我从startup.auth.cs获得的提供程序配置。打开后,包括google提供商在内的所有提供商都会在Challenge上获得一个500内部服务器。但是,内部服务器错误的详细信息不可用,我也不知道如何打开Katana中间件的调试或跟踪。在我看来,他们似乎急于将google Oauth中间件推出。

代码语言:javascript
复制
  //// GOOGLE
        var googleOptions = new GoogleOAuth2AuthenticationOptions
        {
            ClientId = "228",
            ClientSecret = "k",
            CallbackPath = new PathString("/users/epsignin")
            SignInAsAuthenticationType = DefaultAuthenticationTypes.ExternalCookie,
            Provider = new GoogleOAuth2AuthenticationProvider
            {
                OnAuthenticated = context =>
                {
                    foreach (var x in context.User)
                    {
                        string claimType = string.Format("urn:google:{0}", x.Key);
                        string claimValue = x.Value.ToString();
                        if (!context.Identity.HasClaim(claimType, claimValue))
                            context.Identity.AddClaim(new Claim(claimType, claimValue, XmlSchemaString, "Google"));
                    }
                    return Task.FromResult(0);
                }
            }
        };

        app.UseGoogleAuthentication(googleOptions);

ActionMethod代码:

代码语言:javascript
复制
 [AllowAnonymous]
    public ActionResult ExternalProviderSignIn(string provider, string returnUrl)
    {
       var ctx = Request.GetOwinContext();
        ctx.Authentication.Challenge(
            new AuthenticationProperties
            {
                RedirectUri = Url.Action("EPSignIn", new { provider })
            },
            provider);
        return new HttpUnauthorizedResult();
    }
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/21964139

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档