2014-08-27 31 views
1

我在rails/ember應用程序中玩弄omniauth,並且在谷歌登錄時點擊了一面牆。我得到了彈出窗口以允許該網站驗證了我,但點擊接受請求炸彈出來後:Google oauth在本地開發中被阻止

Uncaught SecurityError: Blocked a frame with origin "https://localhost:3001" from 
accessing a frame with origin "https://accounts.google.com". Protocols, domains, 
and ports must match. 

我使用自簽名證書來獲得HTTPS地方發展,但我怎麼在本地測試這個權威性的邏輯?

的CoffeeScript試圖做標誌的:

$ -> 
    $.ajax 
    url: '//apis.google.com/js/client:plus.js?onload=gpAsyncInit' 
    dataType: 'script' 
    cache: true 
window.gpAsyncInit = -> 
    $(".google-login").click (e) -> 
    e.preventDefault() 
    gapi.auth.authorize 
     immediate: false 
     response_type: "code" 
     client_id: "<%= ENV["GOOGLE_CLIENT_ID"] %>" 
     scope: "email profile" 
    , (response) -> 
     if response and not response.error 
     jQuery.ajax 
      type: "POST" 
      url: "/auth/google_oauth2/callback" 
      dataType: "json" 
      data: response 
      success: (json) -> 
      alert 'success!' 
     else 
     alert response.error 

回答

0

嘗試用有效的域,如替換本地主機。 mydevserver.me.com。您可以在/ etc/hosts中將mydevserver.me.com指向127.0.0.1。您還需要將http://mydevserver.me.com/mycallback作爲回調網址添加到Google API控制檯

相關問題