Sam
Sam

Reputation: 5270

How to support different stages for testing facebook authentication

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.

Upvotes: 1

Views: 57

Answers (1)

Tim
Tim

Reputation: 46

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.

Upvotes: 2

Related Questions