Note that there are some explanatory texts on larger screens.

plurals
  1. POemail access using facebook authentication rails
    text
    copied!<p>I am unable to access the user email through facebook authentication. my code in authentication controller</p> <p>def facebook</p> <pre><code> omni= request.env["omniauth.auth"] authentication = Authentication.find_by_provider_and_uid(omni['provider'],omni['uid']) if authentication flash[:notice]="Logged in successfully" sign_in_and_redirect User.find(authentication.user_id) elsif current_user token=omni['credentials'].token token_secret=omni['credentials'].secret current_user.authentications.create!(:provider=&gt;omni['provider'],:uid=&gt;omni['uid'],:token=&gt;token,:token_secret=&gt;token_secret) flash[:notice]="Authentication successful." sign_in_and_redirect current_user else user=User.new # user.email=omni['extra']['raw_info'].email user.apply_omniauth(omni) if user.save flash[:notice]="Logged in." sign_in_and_redirect User.find(user.id) else session[:omniauth]=omni.except('extra') redirect_to new_user_registration_path end end end </code></pre> <p>devise.rb</p> <p>config.omniauth :facebook, 'xxxxxxxxxxxxxxx851','xxxxxxxxxxxxxxxxxxd47aae3', {:scope => ' email,publish_stream,offline_access' ,:display => 'popup'} </p> <p>in user model</p> <pre><code>def apply_omniauth(omni) authentications.build(:provider =&gt; omni['provider'], :uid=&gt;omni['uid'], :token=&gt;omni['credentials'].token, :token_secret=&gt;omni['credentials'].secret, ) x=omni["info"]["name"].split # split the full name into first and last name self.first_name=x[0] self.last_name=x[1] self.profile_name=omni['info']['nickname'] </code></pre> <p>end</p> <p>Is their something in the code?</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload