0
votes

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.

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.

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
2

2 Answers

1
votes

There's no field nickname, do you mean username? If so it's no longer available if you use the Graph API v2.0.

References:

0
votes

I know this is an old question. Since facebook now does not support fetching username at time of login, a workaround for getting user name would be, to call GraphRequest.newMeRequest() from the onSuccess() method of facebook login button