Using Facebook Authentication in Rails Development Environments

posted in: HOWTO | 0

Say you’re building a Rails application and want to use Facebook with Omniauth via Devise. You’ve already got that working and have your Facebook API key registered and all that. But maybe you want to see how it works and test certain things before deploying to Production.

Facebook requires only certain domains be allowed access to your API usage. You might be able to get away with using localhost but maybe not (I’ve not tried it, TBH) plus that is just messy.

Easy fix! Let’s say your app’s public domain is

Edit your /etc/hosts file and add an entry:

In Facebook’s API settings, add that url, to your list of “App Domains”.

website screenshot

If you’re using Unicorn, you may need to specify that you want to use this URL to listen on (it defaults to

$ bundle exec unicorn -l


bundle exec unicorn -l

Either will work.

You should be able to now authenticate while in your dev environment.