Working with Facebook Authentication in a Development Environment

When working with facebook authentication in client mode on the client side with OAuth2, is there a way to check it when working with local development environments to redirect uris?

Obviously, you could specify your IP address and port 80 of the route on this IP address on your computer, but is there an easier way to achieve this?

+5
source share
2 answers

You should have no problem creating your facebook application on your local computer.
Just set the URL on the facebook settings page http: // localhost / yourapp / and work as usual.
All OAuth procedures should work fine.

+7
source

In my experience so far, you can use the same facebook application for dev, testing, staging, production, etc. The key (referenced by lnetanel ) is that the application must have a separate 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 build 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

: localhost.mydomain.com /etc/hosts, , , , .

0

All Articles