Ryan Foster
Ryan Foster

Reputation: 297

Omniauth Facebook authentication on localhost

I am trying to set up Omniauth as described in this Railscast. While it works with Twitter, I am unable to get it working with Facebook. I also set up 'http://localhost:3000' as siteurl and 'localhost' as domain but still see the following error message in the browser:

Invalid redirect_uri: Given URL is not allowed by the Application configuration.

Does anyone of you have any suggestions on how to fix this? Thanks in advance.

Upvotes: 22

Views: 21319

Answers (5)

Gonzalo S
Gonzalo S

Reputation: 894

If you are on OSX you can use pow http://pow.cx/ to rename localhost to

http://yourapp-dev  

(is not really renamed, it's added)

you can set that as a valid domain name on facebook.

Upvotes: 0

Monica
Monica

Reputation: 281

Here's what worked for me.

Right now Facebook does not allow setting the Site Domain to an IP, so it's not possible to set the Site URL to http://127.0.0.1:3000/ because then Facebook will complain that the URL does not match the domain.

So in your Facebook App set the:

Site URL: http://localhost:3000/
Domain: localhost

When you access the app on your dev machine make sure you type in localhost:3000 in the browser. If you use 127.0.0.1:3000 OmniAuth will use that in the callback url it sends to Facebook and then Facebook will throw the error Ryan mentions above.

Upvotes: 28

Josh Crews
Josh Crews

Reputation: 799

I switch to http://lvh.me:3000 in my local browser to test facebook locally. Then in facebook app settings, make lvh.me your domain.

lvh.me is a registered domain pointing to 127.0.0.1 that a developer bought to test subdomains locally.

Upvotes: 15

Chrisjschmitt
Chrisjschmitt

Reputation: 336

Take a look at the redirect in the URI. Mine read localhost:3000 so I changed the Site URL to "http://localhost:3000/" and it worked.

Upvotes: 32

monocle
monocle

Reputation: 5896

Try using

http://0.0.0.0:3000/

for the 'Site URL'. This works for me. (Also, I don't have anything in the 'Site Domain' field.)

Upvotes: 7

Related Questions