Facebook Call Hash Documentation

I am using Omniauth with Devise to authenticate users via Facebook for the web application I am writing using Rails 3.0.4

I modeled it after Rails Bates Railscasts:

http://railscasts.com/episodes/235-omniauth-part-1
http://railscasts.com/episodes/236-omniauth-part-2

At this point, I can log into my site with my Facebook account and pull my email from the callback hash that looks like this for me:

request.env["omniauth.auth"]  

{"user_info"=>  
  {"name"=>"Eric Hu",  
   "urls"=>  
    {"Facebook"=>"http://www.facebook.com/...", "Website"=>nil},  
   "nickname"=>"...",  
   "last_name"=>"Hu",  
   "first_name"=>"Eric"},  
 "uid"=>"...",  
 "credentials"=>  
  {"token"=> "..."},  
 "extra"=>  
  {"user_hash"=>  
    {"name"=>"Eric Hu",  
     "timezone"=>-8,  
     "gender"=>"male",  
     "id"=>"...",  
     "last_name"=>"Hu",  
     "updated_time"=>"2011-02-21T17:46:19+0000",  
     "verified"=>true,  
     "locale"=>"en_US",  
     "link"=>"http://www.facebook.com/...",  
     "email"=>"...",  
     "first_name"=>"Eric"}},  
 "provider"=>"facebook"}  

(replaced some fields with "..." for my own privacy)

Now I use this field to get the email address of the user

 request.env["omniauth.auth"]["user_info"]["extra"]["email"]

, - - Facebook, . , , , - Facebook, . SO Facebook.

: Facebook? , - . , , , , Facebook Omniauth.

+3
1

Facebook, , . , , , . , , .

, , (config/initializers/devise.rb), :

config.omniauth :facebook, FACEBOOK_APP_ID, FACEBOOK_APP_SECRET, {:scope => 'offline_access,email,user_birthday'}
+3

Source: https://habr.com/ru/post/1795852/


All Articles