config.omniauth :facebook, ENV['FB_APP_ID'], ENV['FB_APP_SECRET'],
scope: ['email', 'user_location'],
callback_url: ENV['FB_CALLBACK_URL'],
info_fields: 'email, first_name, last_name, name, location'
这是我的devise.rb配置
OmniauthCallbacksController
在我的facebook
方法的 @user = User.from_omniauth(request.env['omniauth.auth'])
@oauth = Koala::Facebook::OAuth.new(ENV['FB_APP_ID'], ENV['FB_APP_SECRET'], ENV['FB_CALLBACK_URL'])
@graph = Koala::Facebook::API.new(@user.omni_auth_settings.first.access_token)
控制器中,我想创建一个用户并将其本地化分配给他。
=> {"provider"=>"facebook",
"uid"=>"1091157110258285",
"info"=>
{"email"=>"wfhllalscu_1552944302@tfbneew.net",
"name"=>"Emma Alcdgiehdgbgb Fergiesen",
"first_name"=>"Emma",
"last_name"=>"Fergiesen",
"image"=>"http://graph.facebook.com/v2.10/1091157110258285/picture"},
"credentials"=>
{"token"=>
"EAAEobjagyisBAFKrkigZA4p09xvxVOKK41LbPEHKFASCGrz0f5ZCIgwwdjBq1UPf5jvkmdzjhnytZAKVwDb4MrrzWvkC0y1LLJ8RZCpKcA4tTHty3pGxjFvoKzqb5RLYUvSP1Y5GL0A09ZClM5FsEX464sVnmKXXi6Bg4F0qbAYikFFNFQifsQ",
"expires_at"=>1558216434,
"expires"=>true},
"extra"=>
{"raw_info"=>{"email"=>"wfhllalscu_1552944302@tfbnw.net", "first_name"=>"Emma", "last_name"=>"Fergiesen", "name"=>"Emma Alcdgiehdgbgb Fergiesen", "id"=>"1091157110258285"}}}
不幸的是,facebook API仍然仅返回以下数据:
/me
当我直接要求[6] pry(#<Users::OmniauthCallbacksController>)> @graph.get_object("me")
=> {"name"=>"Emma Alcdgiehdgbgb Fergiesen", "id"=>"1091157110258285"}
时,我仍然没有收到生日和本地化信息。
credhub-ref
为这些用户授予特权。我不知道为什么无法获取这些数据。 有什么想法吗?