本文介绍了AngularJS +的WebAPI外部谷歌认证的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我目前正在建立一个外部登录(谷歌)到我的Web应用程序AngularJS是谈论到Web API,所有本地,但我有问题。

I am currently setting up an external login (Google) into my AngularJS WebApp which is talking to a Web API, all locally, however I am having issues.

我已按照关于如何设置谷歌的认证,其中涉及在刚刚加入 app.UseGoogleAuthentication(); 没有的appid或clientSecret像其他供应商如Facebook。

I have followed the steps in http://www.asp.net/web-api/overview/security/external-authentication-services on how to set up google authentication, which involves in just adding app.UseGoogleAuthentication(); without appId or clientSecret like other providers like Facebook.

现在将我的API我查询和使用下列让所有供应商 GET / API /帐号/ ExternalLogins RETURNURL =%2F&放大器; generateState = TRUE ,它的回报<$c$c>[{\"Name\":\"Google\",\"Url\":\"/api/Account/ExternalLogin?provider=Google&response_type=token&client_id=self&redirect_uri=http%3A%2F%2Flocalhost%3A11942%2F&state=E2eXxoZ02yUg39-DrwZTXHnrV5FrOhUe-k-zz-oD6uE1\",\"State\":\"E2eXxoZ02yUg39-DrwZTXHnrV5FrOhUe-k-zz-oD6uE1\"}]

Now going to my API I query and get all providers using following GET /api/Account/ExternalLogins?returnUrl=%2F&generateState=true , which return [{"Name":"Google","Url":"/api/Account/ExternalLogin?provider=Google&response_type=token&client_id=self&redirect_uri=http%3A%2F%2Flocalhost%3A11942%2F&state=E2eXxoZ02yUg39-DrwZTXHnrV5FrOhUe-k-zz-oD6uE1","State":"E2eXxoZ02yUg39-DrwZTXHnrV5FrOhUe-k-zz-oD6uE1"}]

和从互联网阅读我剥去网址<$c$c>/api/Account/ExternalLogin?provider=Google&response_type=token&client_id=self&redirect_uri=http%3A%2F%2Flocalhost%3A11942%2F&state=E2eXxoZ02yUg39-DrwZTXHnrV5FrOhUe-k-zz-oD6uE1并加入到一个锚标记,所以我想这应该重定向我到谷歌的认证,但是我收到一个错误信息

and from reading in the internet I stripped the URL /api/Account/ExternalLogin?provider=Google&response_type=token&client_id=self&redirect_uri=http%3A%2F%2Flocalhost%3A11942%2F&state=E2eXxoZ02yUg39-DrwZTXHnrV5FrOhUe-k-zz-oD6uE1 and added into a anchor tag, so I suppose this should have redirected me to google authentication, however I receive a error message

有谁知道为什么吗?还加入链接时进入一个锚标记我加入的链接,我的API 开始。

Does anyone know why? Also when adding the link into an anchor tag I am adding the link for my API http://localhost:11942/ at the start.

感谢您

推荐答案

您使用的是与谷歌(开放ID)来验证的方法是去precated,请参考:
http://blogs.msdn.com/b/webdev/archive/2014/07/02/changes-to-google-oauth-2-0-and-updates-in-google-middleware-for-3-0-0-rc-release.aspx

The method you are using to authenticate with google (Open ID) is deprecated, refer to:http://blogs.msdn.com/b/webdev/archive/2014/07/02/changes-to-google-oauth-2-0-and-updates-in-google-middleware-for-3-0-0-rc-release.aspx

您需要使用谷歌的OAuth,尝试按照下面的文章来配置谷歌认证:
http://www.asp.net/mvc/overview/security/create-an-aspnet-mvc-5-app-with-facebook-and-google-oauth2-and-openid-sign-on#goog

You need to use Google OAuth, try to follow the following article to configure Google authentication:http://www.asp.net/mvc/overview/security/create-an-aspnet-mvc-5-app-with-facebook-and-google-oauth2-and-openid-sign-on#goog

这篇关于AngularJS +的WebAPI外部谷歌认证的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-07 05:18