2012-03-11 69 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

相關問題