socksocket
socksocket

Reputation: 4371

omniauth with rails: get facebook user's information

in the callback of the authentication process I do:
auth_hash = request.env['omniauth.auth']

and then, I'm extracting the user id, but is it possible in the same time getting the user's name and email address?

Upvotes: 1

Views: 1819

Answers (2)

Aayush Khandelwal
Aayush Khandelwal

Reputation: 1071

yesss

u can get it by doing

     auth_hash[:info][:name] for name and auth_hash[:info][:email] for email

Upvotes: 1

Icicle
Icicle

Reputation: 1174

You need to first get the raw data from request.env["omniauth.auth"]

  data = request.env["omniauth.auth"].extra.raw_info 
  username = data.first_name 
  email  = data.email 

Upvotes: 8

Related Questions