15

I am facing with the problem:

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

I set up in my app the needed keys and tokens, in the Facebook's dev center I set up Site URL: to http://127.0.0.1:3001 and I am getting the error above. Also I tried to set up App Namespace: to http://127.0.0.1:3001, but I am getting error about bad address format... When I tried to fill out he App Domain: and set there my localhost, again the error for the bad format...

What is the correct configuration the fabebook app with localhost?

user984621
  • 46,344
  • 73
  • 224
  • 412

4 Answers4

15

You need to use urls, what I would do add this to your hosts:

127.0.0.1 dev-machine
127.0.0.1 dev-machine.com

Then in the facebook settings use

dev-machine.com as your App Domain

dev-machine.com:3001 as your Site URL

Abe Petrillo
  • 2,368
  • 23
  • 34
7

Yes in FB App you have to assign an IP Site/ App Domain.

  • Facebook matches this url with the url of the request where it came from.
  • You can not assign localhost or 127.0.0.1
  • You have to enter the IP address your server. Also if it is rails then call the site with your-ip:3000 instead of localhost:3000; I use 192.168.1.154:3000
  • Enter the same IP address in IP of the site and APP Domain in your FB APP Settings.
  • To get your IP run ifconfig command in terminal if it is Linux or ipconfig if windows.

let me know if it doesn't work.

Kashyap
  • 479
  • 5
  • 17
  • 1
    which IP are you trying to add? – Kashyap Jun 29 '12 at 10:51
  • 2
    This is a wrongly accepted answer. FB does let you use localhost. But the port (:3000) should be indeed specified in Site URL (ex. http://localhost:3000/). Otherwise (http://localhost/) just won't work. – valk May 31 '14 at 21:23
  • On the development machine I assigned 'http://127.0.0.1:5000/users/auth/facebook/callback' in **devise.rb** callback settings and it works. I have problems with the real host name in production **Heroku** hosting. – Fabrizio Bertoglio Mar 02 '17 at 08:45
1

in the facebook App Page -> the basic tab. find "Website with Facebook Login" Option.

you will find Site URL: input there put the full URL (i.e http:// localhost:3000 if you are in Development mode) [* note : not "App Domains"]

1

I encountered this error and it was incredibly frustrating. The solution? I wasn't actually passing parameters properly in the query string. When I manually built my URL and submitted it using the browser, everything worked fine. Crap.

So, essentially, if you're getting this error it may actually be a symptom of something totally unrelated to the redirect_uri -- it just happens to be the first error triggered when your parameters are messed up. I hope that saves you the hours I spent on this.

Erik Trautman
  • 5,883
  • 2
  • 27
  • 35