for omniuath-twiiter i want to set multiple developers accounts But i am not able set enviroment variable at run time
Please Help
you can add the id and secret into config file like config.yml
and ignore the config.yml
in .gitignore
, track a config.example.yml
file to make every developers easy to use.
omniauth:
providers:
- { name: 'google_oauth2', app_id: 'YOUR_APP_ID',
app_secret: 'YOUR_APP_SECRET',
args: { access_type: 'offline', approval_prompt: '' } }
- { name: 'twitter', app_id: 'YOUR_APP_ID',
app_secret: 'YOUR_APP_SECRET'}
and config omniuath-twiiter
just use params in config.yml via Settingslogic
gem , it is easy to use, put the code into a file in config/initializers/
class Settings < Settingslogic
source "#{Rails.root}/config/config.yml
namespace Rails.env
end
module Foobar
def self.config
Settings
end
end
then config the omniauth like below:
Foobar.config.omniauth.providers.each do |provider|
config.omniauth provider['name'].to_sym, provider['app_id'], provider['app_secret'], provider['args']
end
that's it
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.