Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/316.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
C# DNOA OpenID+;从本地主机和公共站点到Google的OAuth失败_C#_Asp.net Mvc_Openid_Dotnetopenauth_Appharbor - Fatal编程技术网

C# DNOA OpenID+;从本地主机和公共站点到Google的OAuth失败

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

我在我的网站上使用DNOA与谷歌进行身份验证和授权

当我在本地主机上运行时,会出现此错误

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应用程序

注册分为三个级别:

  • 未注册:谷歌无法识别应用程序。通道 请求页面,提示用户授予或拒绝访问权限 对于您的应用程序,以黄色突出显示此警告: “此网站尚未在谷歌注册。我们建议您 仅当您信任此目标时,才能继续此过程。“

  • 注册:

  • 已向增强安全性注册:

  • 注册是可选的,但建议

    我甚至尝试在appHarbor上发布,但没有任何帮助(那里还没有日志)


    如何解决这个问题?

    您看到的错误消息是因为OpenID规范要求返回URL是领域URL的派生,而在您的情况下,显然不是。不在任何地方。如果您将领域设置为站点的实际根URL,以便return_to位于其下,则此错误应消失


    我很想看看谷歌的文档,上面说它接受匿名以外的任何东西的领域和回报

    你能完成并运行这个项目吗@EladBenda我认为您混淆了库对普通OAuth 1.0的使用和这个问题对OpenID+OAuth扩展的使用。它们是完全不同的场景,虽然DNOA和matlus的库都可以用Google实现匿名OAuth,但这两个库(我相信)都不能实现匿名OpenID+OAuth扩展。