Rails,使用omniauth-google-oauth2获得circledByCount

时间:2015-10-19 17:33:58

标签: ruby-on-rails ruby google-authentication

我使用omniauth-google-oauth2 gem并希望让我的圈子中的所有人都加入google plus帐户,我的omniauth文件:

Rails.application.config.middleware.use OmniAuth::Builder do
  provider :twitter, ENV['twitter_key'], ENV['twitter_secret'], info_fields: 'followers_count'
  provider :instagram, ENV['instagram_key'], ENV['instagram_secret'], info_fields: 'follows'
  provider :facebook, ENV['facebook_key'], ENV['facebook_secret'], info_fields: 'friends'
  google_scope = "plus.login"

  provider :google_oauth2, ENV['google_key'], ENV['google_secret'], scope: google_scope, access_type: "offline"
end

但是request.env ['omniauth.auth']返回:

"id_info"=>
{"iss"=>"accounts.google.com",
 "at_hash"=>"secret",
 "aud"=>"secret",
 "sub"=>"secret",
 "azp"=>"secret",
 "iat"=>1445275484,
 "exp"=>1445279084},
"raw_info"=>
{"kind"=>"plus#personOpenIdConnect",
 "gender"=>"male",
 "sub"=>"103458288129240855409",
 "name"=>"Sergey Naumenko",
 "given_name"=>"Sergey",
 "family_name"=>"Naumenko",
 "profile"=>"https://plus.google.com/103458288129240855409",
 "picture"=>"https://lh6.googleusercontent.com/-b8p4jlJRIm8/AAAAAAAAAAI/AAAAAAAAAV4/rZXezwwCy7w/photo.jpg?sz=50",
 "locale"=>"en"}}}

我需要获得circledByCount

谁能帮帮我?

1 个答案:

答案 0 :(得分:0)

我通过添加选项skip_friends:false

修复了它
provider :google_oauth2, ENV['google_key'], ENV['google_secret'], scope: google_scope, skip_friends: false