C# DNOA OpenID+;从本地主机和公共站点到Google的OAuth失败
我在我的网站上使用DNOA与谷歌进行身份验证和授权 当我在本地主机上运行时,会出现此错误C# DNOA OpenID+;从本地主机和公共站点到Google的OAuth失败,c#,asp.net-mvc,openid,dotnetopenauth,appharbor,C#,Asp.net Mvc,Openid,Dotnetopenauth,Appharbor,我在我的网站上使用DNOA与谷歌进行身份验证和授权 当我在本地主机上运行时,会出现此错误 return_to 'http://localhost:8976/Register/Login' not under realm 'http://anonymous/'. 根据这段代码: private void HandleAuthNullResponse(IAuthenticationResponse authResponse) { // Google re
return_to 'http://localhost:8976/Register/Login' not under realm 'http://anonymous/'.
根据这段代码:
private void HandleAuthNullResponse(IAuthenticationResponse authResponse)
{
// Google requires that the realm and consumer key be equal,
// so we constrain the realm to match the realm in the web.config file.
// This does mean that the return_to URL must also fall under the key,
// which means this sample will only work on a public web site
// that is properly registered with Google.
// We will customize the realm to use http or https based on what the
// return_to URL will be (which will be this page).
var consumer = new WebConsumer(GoogleConsumerHelper.ServiceDescription, mConsumerTokenManager);
//Realm realm = "http://localhost:8976/";
Realm realm = System.Web.HttpContext.Current.Request.Url.Scheme + Uri.SchemeDelimiter + consumer.ConsumerKey + "/";
IAuthenticationRequest authReq = GoogleConsumerHelper.RelyingParty.CreateRequest(GoogleConsumerHelper.GoogleOPIdentifier, realm);
该错误与DNOA的评论相符
这很奇怪,因为我看到了其他适用于localhost的代码,但其结构化程度要低得多
然后我转到谷歌网站,看到:
注册您的web应用程序
注册分为三个级别:
如何解决这个问题?您看到的错误消息是因为OpenID规范要求返回URL是领域URL的派生,而在您的情况下,显然不是。不在任何地方。如果您将领域设置为站点的实际根URL,以便return_to位于其下,则此错误应消失
我很想看看谷歌的文档,上面说它接受匿名以外的任何东西的领域和回报 你能完成并运行这个项目吗@EladBenda我认为您混淆了库对普通OAuth 1.0的使用和这个问题对OpenID+OAuth扩展的使用。它们是完全不同的场景,虽然DNOA和matlus的库都可以用Google实现匿名OAuth,但这两个库(我相信)都不能实现匿名OpenID+OAuth扩展。