Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/wpf/13.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Google oauth 带有Web API的Extern auth服务-无法使示例正常工作_Google Oauth_Asp.net Web Api2 - Fatal编程技术网

Google oauth 带有Web API的Extern auth服务-无法使示例正常工作

Google oauth 带有Web API的Extern auth服务-无法使示例正常工作,google-oauth,asp.net-web-api2,Google Oauth,Asp.net Web Api2,我无法让样本与谷歌合作。我按照说明创建了一个项目。然而,我注意到我的项目在Startup.ConfigureAuth方法中创建了一个稍微不同的代码 app.UseGoogleAuthentication(new GoogleOAuth2AuthenticationOptions() { ClientId = "<valid client id here>", ClientSecret

我无法让样本与谷歌合作。我按照说明创建了一个项目。然而,我注意到我的项目在Startup.ConfigureAuth方法中创建了一个稍微不同的代码

        app.UseGoogleAuthentication(new GoogleOAuth2AuthenticationOptions()
        {
            ClientId = "<valid client id here>",
            ClientSecret = "<valid secret here>",
        });
示例中的代码没有初始化部分,但如果没有初始化部分,代码甚至无法编译


当我运行应用程序时,我会在登录屏幕上选择使用Google作为服务登录。然后我被带到谷歌的网站,要求允许我的应用程序使用我的信息。应用程序的名称似乎是正确的,所以我必须假设上面提供的ClientId/ClientSecret是正确的。但是,当我单击“允许”按钮时,我会返回到登录页面,而不是示例中所示的注册页面。是否有人能够使用Google身份验证使示例正常工作?如果是,请分享解决方法,如果有的话。谢谢。

我终于在这个网站上的一篇文章的帮助下找到了问题的根源。不幸的是,我失去了这篇文章的链接。无论如何,解决方案是确保在项目的Google控制台中启用Google+API-默认情况下不启用它们。详细信息可以按照帖子的建议找到。

我个人使用了谷歌.net客户端库。但是您应该被重定向到您在Google开发者控制台中设置重定向uri的位置。