Running rails 3.2.18 on c9.io, and I have the gems omniauth and omniauth-google-oauth2 installed. I ran into a problem where I would get a CSRF error on the callback, and it sounded like adding "provider_ignores_state: true" to the params would prevent that, at least for testing and development. It did get rid of the CSRF error, but now there is a new error:
OAuth2::Error
invalid_request: Missing required parameter: code
{
"error" : "invalid_request",
"error_description" : "Missing required parameter: code"
}
my config/initializers/omniauth.rb
Rails.application.config.middleware.use OmniAuth::Builder do
provider :google_oauth2, "clientID", "clientSecret",
scope: 'profile', image_aspect_ratio: 'square', image_size: 48, access_type: 'online', name: 'google', provider_ignores_state: true
end
Top few lines from the trace:
oauth2 (1.0.0) lib/oauth2/client.rb:113:in `request'
oauth2 (1.0.0) lib/oauth2/client.rb:138:in `get_token'
oauth2 (1.0.0) lib/oauth2/strategy/auth_code.rb:29:in `get_token'
omniauth-oauth2 (1.3.1) lib/omniauth/strategies/oauth2.rb:93:in `build_access_token'
omniauth-google-oauth2 (0.2.6) lib/omniauth/strategies/google_oauth2.rb:77:in `custom_build_access_token'
EDIT: Adding the versions for the gems
/usr/local/rvm/gems/ruby-1.9.3-p547/gems/omniauth-1.2.2
/usr/local/rvm/gems/ruby-1.9.3-p547/gems/omniauth-google-oauth2-0.2.6
答案 0 :(得分:0)
所以问题出在视野中!我应该尝试使用/ auth / google / callback,它应该只是/ auth / google。 花了太长时间才弄明白......