Note that there are some explanatory texts on larger screens.

plurals
  1. POEmpty Session after Omniauth Twitter Callback
    text
    copied!<p>I'm trying to build an Application that is using the OmniAuth gem, so that Twitter users can login.</p> <p>I followed the steps in the tutorials and i'm pretty sure, that i've done everything right.</p> <p>But on the callback from Twitter i get this infamous error message:</p> <pre><code>NoMethodError You have a nil object when you didn't expect it! You might have expected an instance of ActiveRecord::Base. The error occurred while evaluating nil.[] </code></pre> <p>After digging deeper in the omniauth gem, i figured out, that in the <code>OAuth#callback_phase</code> the session does not contain any oauth information</p> <pre><code>def callback_phase ::Rails.logger.info "session: #{session.inspect}" ::Rails.logger.info "consumer: #{consumer.inspect}" request_token = ::OAuth::RequestToken.new(consumer, session['oauth'][name.to_s].delete('request_token'), session['oauth'][name.to_s].delete('request_secret')) ... end </code></pre> <p>Log after callback</p> <pre><code>session: {"session_id"=&gt;"190523311f7a63fe796558691b1d4fff"} consumer: #&lt;OAuth::Consumer:0x103735b50 @secret="...", @http=#&lt;Net::HTTP api.twitter.com:443 open=false&gt;, @key="...", @options={:access_token_path=&gt;"/oauth/access_token", :proxy=&gt;nil, :http_method=&gt;:post, :site=&gt;"https://api.twitter.com", :request_token_path=&gt;"/oauth/request_token", :scheme=&gt;:header, :oauth_version=&gt;"1.0", :signature_method=&gt;"HMAC-SHA1", :authorize_path=&gt;"/oauth/authenticate"}&gt; </code></pre> <p>So it looks like the Session content is not filled or gets lost on the way from twitter to omniauth.</p> <p>Does anyone have a idea, what can cause the behavior?</p> <p>My Gemfile:</p> <pre><code>gem 'mongrel', '1.2.0.pre2' gem "rails", "~&gt; 3.0.6" gem "mysql" gem 'omniauth' gem 'settingslogic' # config/application.yml gem 'will_paginate', '~&gt; 3.0.beta' </code></pre> <p>Thanks for your help in advance.</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