Question

I am developing a rails application using omniauth-facebook for authentication. I have 3 different stages (localhost, staging.mycompany.com, production.mycompany.com) for testing purposes

How should I register the facebook application, should I do it for all 3 stages https://developers.facebook.com/x/apps/appid/settings/ (appid is the reference to my Facebook application)

Since the Site URL will be different for all 3 stages above.

Was it helpful?

Solution

Just register 3 different apps and create a yaml file with those keys (social.yml). Something like:

development:
  fb_key: 123
  fb_secret: abc
production:
  fb_key: 345
  fb_secret: def      

Then create a global variable of it in an initializer:

SOCIAL_CONFIG = YAML.load_file("#{::Rails.root}/config/social.yml")[::Rails.env]

This way you always use the right key for the environment your in.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top