问题描述
我已经将Rails 3应用程序设置为使用omniauth-facebook,一切正常,但是当我将yaml视为omniauth哈希时,没有昵称"字段,我可以获取名称"和电子邮件"但是我的验证无法创建用户,因为我无法获取应用程序用户名要求的昵称.
I've set up my rails 3 app to use omniauth-facebook, everything works fine but when I look at the omniauth hash as yaml there is no 'nickname' field, I can get the 'name' and 'email' but my validations fail to create a user because I can't grab the nickname for my app's username requirement.
我已经在设置"下仔细检查了我的Facebook帐户,并显示了我的用户名.知道为什么会这样吗?感谢您的帮助.
I've double checked my facebook account, under "Settings", and my username is displayed. ANy ideas why this would be happening? Thanks for the help.
以下是我的omniauth哈希的示例,出于隐私原因,我将"X"置于"
Here is an example of my omniauth hash, i've placed 'X' for privacy reason:
--- !ruby/hash:OmniAuth::AuthHash
provider: facebook
uid: 'XXXXXXXXXXXXX'
info: !ruby/hash:OmniAuth::AuthHash::InfoHash
email: [email protected]
name: XXXX XXXX
first_name: XXXX
last_name: XXXX
image: http://graph.facebook.com/XXXXXXXXXXXXX/picture
urls: !ruby/hash:OmniAuth::AuthHash
Facebook: https://www.facebook.com/app_scoped_user_id/XXXXXXXXXXXXX/
verified: true
credentials: !ruby/hash:OmniAuth::AuthHash
token: ACCESS_TOKEN
expires_at: 1406357169
expires: true
extra: !ruby/hash:OmniAuth::AuthHash
raw_info: !ruby/hash:OmniAuth::AuthHash
id: 'XXXXXXXXXXXXXXX'
email: [email protected]
first_name: XXXX
gender: male
last_name: XXXX
link: https://www.facebook.com/app_scoped_user_id/XXXXXXXXXXXXX/
locale: en_US
name: XXXX XXXX
timezone: 7
updated_time: '2014-05-07T00:58:12+0000'
verified: true
推荐答案
没有字段nickname
,您是说username
吗?如果是这样,则在使用Graph API v2.0时将不再可用.
There's no field nickname
, do you mean username
? If so it's no longer available if you use the Graph API v2.0.
参考文献:
- https://developers.facebook.com/docs/apps/changelog#v2_0_graph_api
- https://developers.facebook.com /docs/graph-api/reference/v2.0/user/#fields
- https://developers.facebook.com/docs/apps/changelog#v2_0_graph_api
- https://developers.facebook.com/docs/graph-api/reference/v2.0/user/#fields
这篇关于使用Rails 3,Omniauth-facebook哈希未显示Facebook“用户名"字段的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!