2012-03-11 67 views
0

我在我的网站中使用DNOA进行身份验证和授权。DNOA OpenID +从本地主机和公共站点到Google的OAuth失败

http://ugi-2.apphb.com/Authentication.htm

当我本地主机上运行我从这段代码得到这个错误

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

评论

这很奇怪,因为我看到其他代码适用于本地主机但是结构更少。

我然后转向谷歌的网站,看到:

注册您的Web应用程序

有三个级别的注册:

  1. 未注册的:应用程序不被谷歌认可。访问 请求页面会提示您的用户为您的应用程序授予或拒绝访问 显示以黄色突出显示的此警告: “本网站尚未向Google注册。我们建议您只有在您信任的情况下才会继续此过程这个目的地。“

  2. 注册:...

  3. 增强安全注册:...

注册是可选的,但建议。 ...

我甚至尝试对appHarbor发布,但这并没有帮助(没有日志有尚)

我如何来解决这一问题?

+0

@Andrew Arnott,有什么想法? – 2012-03-16 00:27:33

回答

0

您看到的错误消息是因为OpenID规范要求return_to网址是领域URL的衍生产品,并且显然在您的情况下并非如此。 http://localhost/不属于http://anonymous/下的任何地方。如果您将自己的领域设置为您网站的实际根网址,以便return_to位于其下,则此错误应该消失。

我很希望看到来自Google的文档说明它接受http://anonymous/的领域和返回任何匿名以外的内容。

+0

你能否请你下载并运行这个项目? http://www.matlus.com/oauth-c-library/ – 2012-03-17 08:50:29

+0

@EladBenda我认为你会将图书馆对普通OAuth 1.0的使用与这个问题对OpenID + OAuth扩展的使用混为一谈。他们是完全不同的场景,虽然DNOA和matlus的图书馆都可以与谷歌做匿名OAuth,但两家图书馆(我相信)都可以做匿名OpenID + OAuth扩展。 – 2012-03-18 17:44:58

相关问题