Re: Facebook login only works when hosts is set to localhost?

385 views
Skip to first unread message

howesc

unread,
Aug 27, 2012, 10:48:46 AM8/27/12
to web...@googlegroups.com
you need to have a different FB app for test and for production.  on facebook you set the valid domain for an app, and that is the only domain that it will accept redirect_uri to.  (unless FB has improved and you can set multiple domains per app....but in either case you have to login to FB and update the app settings).

cfh

On Sunday, August 26, 2012 6:24:36 AM UTC-7, user1438003 wrote:

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

Note that I followed your guide for setting up Facebook with OAuth2: http://web2py.com/books/default/chapter/29/9

FYI: I also posted on StackOverflow

Reply all
Reply to author
Forward
0 new messages