Note that there are some explanatory texts on larger screens.

plurals
  1. POOmniauth not updating OAuth token secret on log in
    primarykey
    data
    text
    <p>I'm using Omniauth to authenticate users with Twitter and Facebook, going by the "standard" tutorial on the topic (<a href="http://railscasts.com/episodes/236-omniauth-part-2" rel="nofollow">Ryan Bates' screencast</a>, although I'm using Authlogic, not Devise).</p> <p>I can log in using Twitter, but can't handle authenticated requests back because my Twitter access token secret has been changed on Twitter's end, but is not being updated on my application's end. I've tried deleting the authentication, but it just saves the old one for some reason.</p> <p>authentications_controller.rb</p> <pre><code>def create omniauth = request.env['omniauth.auth'] authentication = Authentication.find_by_provider_and_uid(omniauth['provider'], omniauth['uid']) if authentication # User is already registered with application flash[:notice] = 'Signed in successfully.' sign_in_and_redirect(authentication.user) elsif current_user # User is signed in but has not already authenticated with this social network current_user.authentications.create!(:provider =&gt; omniauth['provider'], :uid =&gt; omniauth['uid'], :token =&gt; (omniauth['credentials']['token'] rescue nil), :secret =&gt; (omniauth['credentials']['secret'] rescue nil)) current_user.apply_omniauth(omniauth) current_user.save flash[:notice] = 'Authentication successful.' redirect_to root_url else # User is new to this application @user = User.new @user.apply_omniauth(omniauth) if @user.save flash[:notice] = 'User created and signed in successfully.' sign_in_and_redirect(@user) else session[:omniauth] = omniauth.except('extra') redirect_to new_user_path end end end </code></pre> <p>user.rb</p> <pre><code>def apply_omniauth(omniauth) self.email = "foo@example.com" self.login = omniauth['user_info']['nickname'] if login.blank? authentications.build(:provider =&gt; omniauth['provider'], :uid =&gt; omniauth['uid'], :token =&gt; omniauth['credentials']['token'], :secret =&gt; omniauth['credentials']['secret']) end </code></pre> <p>Any ideas? Rails 3.0.6 and Ruby 1.8.7</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

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