谷歌认证使用OWIN的Oauth在MVC5不打ExternalLoginCallback功能 [英] Google Authentication using OWIN Oauth in MVC5 not hitting ExternalLoginCallback function

查看:166
本文介绍了谷歌认证使用OWIN的Oauth在MVC5不打ExternalLoginCallback功能的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我目前我的升级登录过程,因为他们自己贬值了OpenID登录方法之前,谷歌为使用OAuth。

I am currently upgrading my login process for Google to use OAuth before they depricate their OpenID login method.

到目前为止,我已经确定的步骤是,我因为这版本升级包Microsoft.Owin.Security.Google到2.1.0版本包括包括在UseGoogleAuthentication方法选项的能力。

The steps I have Identified so far is that I have upgraded the package Microsoft.Owin.Security.Google to version 2.1.0 as this version includes the ability to include options in the UseGoogleAuthentication method.

我曾尝试使用亚历克斯小麦的解决方案中的链接:
获取ExtraData从MVC5框架的OAuth / OWin身份提供与外部认证提供商

I have tried to use Alex Wheat's Solution in the link: Get ExtraData from MVC5 framework OAuth/OWin identity provider with external auth provider

在Startup.Auth.cs(其中还包括Facebook验证)的code从这个云:

The code in Startup.Auth.cs (which also includes Facebook authentication) goes from this:

    var facebookAuthenticationOptions = new FacebookAuthenticationOptions()
        {
            AppId = "MYAPPID",
            AppSecret = "MYSECRET"
        };
        facebookAuthenticationOptions.Scope.Add("email");
        app.UseFacebookAuthentication(facebookAuthenticationOptions);

        app.UseGoogleAuthentication();

要这样:

var facebookAuthenticationOptions = new FacebookAuthenticationOptions()
        {
            AppId = "MYAPPID",
            AppSecret = "MYSECRET"
        };
        facebookAuthenticationOptions.Scope.Add("email");
        app.UseFacebookAuthentication(facebookAuthenticationOptions);


        var googleOAuth2AuthenticationOptions = new GoogleOAuth2AuthenticationOptions
        {
            ClientId = "MYCLIENTID",
            ClientSecret = "MYSECRET",
            CallbackPath = new PathString("/en/Account/ExternalLoginCallback"),
            Provider = new GoogleOAuth2AuthenticationProvider()
            {

            }
        };

        app.UseGoogleAuthentication(googleOAuth2AuthenticationOptions);

在我选项添加到谷歌认证,我的应用程序不允许被要求无论是谷歌或Facebook的ExternalLoginCallback动作(不改变Facebook的code,但问题仍然影响它)。

After I add options to the Google Authentication, my app does not allow the ExternalLoginCallback action to be called for either google or facebook (no changes to facebook code but the issue still affects it).

在前端,点击外部登录按钮后,页面重定向我下面的链接,并返回一个空的白色屏幕

On the front end, after clicking the external login buttons, the page redirects me to the link below and returns an empty white screen

HTTPS ...... / EN /帐号/ ExternalLoginCallback#__ = _(实际上只有等号(=)前一个下划线,所以语法删除它,如果我有它,因为它出现在我的地址栏中)。

https....../en/Account/ExternalLoginCallback#__=_ (There is actually only a single underscore before the = sign, SO syntax removes it if I have it as it appears on my address bar).

对于Facebook以及

for facebook and

HTTPS ...... / EN /帐号/ ExternalLoginCallback

https....../en/Account/ExternalLoginCallback

有关谷歌。它不打下面的控制器方法,因为它一般不会(我试图把这个函数中的调试断点,当有谷歌认证选项时,它永远不会停止。

for google. It does not hit the controller method below as it normally does (I have tried to place debug breakpoints within this function and it never gets stopped when there are google authentication options.

    // GET: /Account/ExternalLoginCallback
    [AllowAnonymous]
    public async Task<ActionResult> ExternalLoginCallback(string returnUrl)
    {

如果我删除谷歌认证的认证方案,它只是恢复到旧的OpenID登录,并再次正常工作。

If I remove the authentication options from Google Authentication, it just reverts back to the old OpenID login and works fine again.

我在这里丢失了一些东西简单?或者是有在Owin.Security.Google图书馆内坏事发生,是造成这个问题?

Am I missing something simple here? or is there something bad happening inside the Owin.Security.Google Library that is causing the problem?

推荐答案

尝试仅仅这

var googleOAuth2AuthenticationOptions = new GoogleOAuth2AuthenticationOptions
        {
            ClientId = "MYCLIENTID",
            ClientSecret = "MYSECRET",
        };
app.UseGoogleAuthentication(googleOAuth2AuthenticationOptions);

这为我工作

这篇关于谷歌认证使用OWIN的Oauth在MVC5不打ExternalLoginCallback功能的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆