這樣做的設置在Omniauth 1.1.0的setup phase
您現在已經改變了你的omniauth.rb
provider_keys = YAML.load_file(File.join(Rails.root, 'config', 'provider_keys.yml'))
SETUP_PROC = lambda do |env|
env['omniauth.strategy'].options[:client_id] = provider_keys[Rails.env]['facebook'][server_name]['consumer_key']
env['omniauth.strategy'].options[:client_secret] = provider_keys[Rails.env]['facebook'][server_name]['consumer_secret']
end
Rails.application.config.middleware.use OmniAuth::Builder do
provider :facebook, setup: SETUP_PROC
end
設置這和您的provider_keys.yml會是這個樣子
development:
facebook:
www.example.heroku.com:
consumer_key: 'xxxxxxxx'
consumer_secret: 'xxxxxxxx'
www.example.com:
consumer_key: 'xxxxxxx'
consumer_secret: 'xxxxxxx'
來源
2012-05-25 04:30:07
fzf
解決方案:https://github.com/intridea/omniauth/wiki/Dynamic-Providers/eb14c359a585a9e8e445a9a8ea7c46d8fb0e7358 –