简体   繁体   中英

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.

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM