2017-09-14 115 views
0

背景

我有一個EC2實例託管一個網站。該網站使用Google的OAuth2 API進行驗證(又名Google Identity Platform)。Google OAuth2不適用於Amazon EC2實例的公共DNS?

該實例具有類似http://ec2-99-99-99-99.compute-1.amazonaws.com的公共DNS。

該URL已添加到憑證管理門戶中的「授權JavaScript起源」部分。

回到客戶端,用戶使用Google登錄按鈕小部件進行身份驗證。

問題

當谷歌小部件嘗試列出不同的登錄選項時,Google小部件失敗。對於新鮮登錄它看起來像這樣: Google Widget Failure

檢查網絡面板顯示此調用失敗:

https://accounts.google.com/o/oauth2/iframerpc?action=listSessions&client_id=...&origin=http%3A%2F%2Fec2-99-99-99-99.compute-1.amazonaws.com&scope=openid%20profile%20email&ss_domain=http%3A%2F%2Fec2-99-99-99-99.compute-1.amazonaws.com 

{ 
    "error" : "invalid_request", 
    "error_description" : "Permission denied to generate login hint for target domain." 
} 

調查說明

  • 這不是一個SSL問題,因爲其他URL一樣http://localhost:9000工作精細。
  • 這與redirect_uri不存在問題,因爲其他網址無法正常工作。

回答

0

看起來,無論出於何種原因,谷歌明確不喜歡亞馬遜構建的默認實例網址。

我們的解決方案是使用指向我們的ec2實例的新自定義域,例如:http://something.anotherdomain.com