Search code examples
ruby-on-railsfacebookruby-on-rails-3omniauthfacebook-oauth

Omniauth-facebook hash not showing Facebook 'username' field, using rails 3


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: XXXX@XXXX.XX
  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: XXXX@XXXX.XX
    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

Solution

  • 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: