Facebook登录仅在主机设置为localhost时有效?

use*_*003 5 facebook hosts oauth-2.0 facebook-login openshift

不幸的是我一直收到这个错误:

{
   "error": {
      "message": "Invalid redirect_uri: Given URL is not allowed by the Application configuration.",
      "type": "OAuthException",
      "code": 191
   }
}
Run Code Online (Sandbox Code Playgroud)

登录有效但是当我的/etc/hosts文件设置为:时127.0.0.1 [mysite].rhcloud.com,它只在我查看实际情况时失败[mysite].rhcloud.com.

我在本地运行完全相同的应用程序(在不同的服务器上)作为我在rhcloud上运行的应用程序.特别是本地< - >远程Web应用程序目录已同步.

网址信息

尝试远程登录时,URL看起来像这样; 并因上述错误而失败:

https://graph.facebook.com/oauth/authorize?scope=user_photos%2Cfriends_photos&redirect_uri=http%3A%2F%2F[mypublicipaddress]%2Fuser%2Flogin&response_type=code&client_id=[hidden]

尝试在本地登录的URL看起来像这样; 并且工作:

https://www.facebook.com/dialog/permissions.request?app_id=[hidden]&display=page&next=http%3A%2F%2F[hidden].rhcloud.com%2Fuser%2Flogin&response_type=code&perms=user_photos%2Cfriends_photos&fbconnect= 1

Igy*_*Igy 1

好的,您似乎做得对,但有一件事有时会让人绊倒,您的字段redirect_uri和“网站 URL”字段是否都有尾随“/”?

特别是,如果redirect_uri域名后面没有尾随“/”(或文件名等),则它并不总是有效