开发者

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.


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.


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.


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.


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.)


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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜