Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

OmniAuth - Facebook login not supplying email in user_info

I'm using OmniAuth, and after logging in via Facebook, I get my omniauth.auth key, which looks like this:

user_info: 
  name: Tim Sullivan
  urls: 
    Facebook: http://www.facebook.com/...
    Website: 
  nickname: ...
  last_name: Sullivan
  first_name: Tim
uid: "123456789"
credentials: 
  token: [some token]
extra: 
  user_hash: 
    name: Tim Sullivan
    timezone: -5
    gender: male
    id: "123456789"
    last_name: Sullivan
    updated_time: 2010-12-30T00:52:39+0000
    verified: true
    locale: en_US
    link: http://www.facebook.com/...
    email: [email protected]
    first_name: Tim
provider: facebook

Now, according to the docs, the email should be in the user_info section, but it isn't. It is, however, in the extra/user_hash section. Since I'm stripping extra, it's not getting stored, so later on down the pipe I'm having problems. I could add it myself, but that doesn't explain why it's not there in the first place.

Why isn't email being put into the user_info section? A bug? Undocumented change?

like image 440
Tim Sullivan Avatar asked Feb 19 '11 03:02

Tim Sullivan


2 Answers

moved to

email = omniauth["extra"]["raw_info"]["email"]
like image 104
marmarko Avatar answered Nov 25 '22 14:11

marmarko


The hash "info" contains all the information of the User:

email = omniauth["info"]["email"]
like image 32
Tiago Avatar answered Nov 25 '22 14:11

Tiago