Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Facebook login only works when hosts is set to localhost?

Unfortunately I keep getting this error:

{
   "error": {
      "message": "Invalid redirect_uri: Given URL is not allowed by the Application configuration.",
      "type": "OAuthException",
      "code": 191
   }
}

Login works however when my /etc/hosts file is set to: 127.0.0.1 [mysite].rhcloud.com, it only fails when I view the actual [mysite].rhcloud.com.

I am running the exact same application (on a different server) locally as the one I'm running on rhcloud. Specifically the local<->remote web-application directories are synced.

URL information

When attempting login remotely the URL looks like this; and fails with aforementioned error:

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]

Whereas attempting to login locally the URL looks like this; and works:

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

like image 586
user1438003 Avatar asked Nov 13 '22 00:11

user1438003


1 Answers

OK, you seem to be doing this right, but there's one thing that sometimes trips people up, do both your redirect_uri and 'Website URL' field have a trailing '/'?

In particular, if the redirect_uri doesn't have the trailing '/' (or a filename, etc) after the domain name it doesn't always work

like image 200
Igy Avatar answered Jan 06 '23 01:01

Igy