0

I've configured devise + omniauth as documented on omniauth wiki: https://github.com/intridea/omniauth/wiki/Setup-Phase

My initializer:

provider :twitter, nil, nil, setup: true

routes.rb:

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

This is the setup action

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

Result is 400 Bad Request and I have no idea why... I checked and the right application is called, setting the right values in the "omniauth.strategy".

Maybe someone who already implemented this can guess what's the problem with my code? Thanks in advance.

4

1 回答 1

0

这是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

于 2015-10-01T13:52:18.653 回答