Raiders
Raiders

Reputation: 141

Working with Facebook Authentication in a Development Environment

When working with facebook authentication in a client-side server side mode with OAuth2, is there any way to test it out while working with local development environments for the redirect uris?

Obviously you could specify your IP and route port 80 on that IP to your computer, but is there a more simple way to achieve this?

Upvotes: 5

Views: 1778

Answers (2)

pduey
pduey

Reputation: 3796

In my experience so far, you can use the same facebook application for dev, testing, staging, production, etc. The key (alluded to by lnetanel) is that the app should have a distinct return URL configured for each environment. For example, I use devise+omniauth, and have the following in .../config/initializers/omnniauth.rb, which is used to construct return URLs:

if Rails.env.production?
  OmniAuth.config.full_host = "https://www.mydomain.com"
elsif Rails.env.test?
  OmniAuth.config.full_host = "https://www.stag.mydomain.com"
elsif Rails.env.development?
  OmniAuth.config.full_host = "https://localhost.mydomain.com"
end

Note, I have a habit of adding localhost.mydomain.com in my local /etc/hosts file so there are no cross domain issues during development, though that is probably not relevant here.

Upvotes: 0

lnetanel
lnetanel

Reputation: 1118

you shouldn't have any problems developing a facebook app locally.
Just set the url's on facebook settings page to http://localhost/yourapp/ and work as usual.
All the OAuth procedures should work normally.

Upvotes: 7

Related Questions