具有 omniauth 的多个 Twitter 应用程序

Multiple Twitter applications with omniauth

我已经按照 omniauth wiki 上的记录配置了 devise + omniauth:https://github.com/intridea/omniauth/wiki/Setup-Phase

我的初始化程序:

provider :twitter, nil, nil, setup: true

routes.rb:

get '/settings/auth/:provider/setup' => 'settings/authorization_callbacks#setup'

这是设置操作

def setup
  application_id = params[:application_id].present? ? params[:application_id] : request.env["rack.session"]["omniauth.params"]["application_id"]
  application = Application.find(application_id)
  request.env['omniauth.strategy'].options[:client_id] = application.identifier
  request.env['omniauth.strategy'].options[:client_secret] = application.secret
  render :text => "Setup complete.", :status => 404
end

结果是 400 Bad Request,我不知道为什么... 我检查并调用了正确的应用程序,在 "omniauth.strategy".

中设置了正确的值

也许已经实现了这个的人可以猜到我的代码有什么问题?提前致谢。

这是 omniauth-twitter 中的一个错误 gem。

为 Twitter 设置的键是

request.env['omniauth.strategy'].options[:consumer_key] = application.identifier
request.env['omniauth.strategy'].options[:consumer_secret] = application.secret

https://github.com/arunagw/omniauth-twitter/issues/100