background: trying to use the twitter gem for ruby-on-rails.
in routes:
map.resources :twitter_sessions
map.finalize_twitter_sessions 'twitter_sessions/finalize', :controller => 'twitter_sessions', :action => 'finalize'
(twitter_sessions is the controller for the twitter sessions in my app).
The view has one file new.html.erb
and is very simple:
<% form_tag(twitter_sessions_path) do |f| %>
<p><%= submit_tag "twitter!" %></p>
<% end %>
and the twitter_sessions_controller.rb:
def new
end
def create
oauth.set_callback_url(finalize_twitter_sessions_url)
session['rtoken'] = oauth.request_token.token
session['rsecret'] = oauth.request_token.secret
redirect_to oauth.request_token.authorize_url
end
def destroy
reset_session
redirect_to new_session_path
end
def finalize
oauth.authorize_from_request(session['rtoken'], session['rsecret'], params[:oauth_verifier])
profile = Twitter::Base.new(oauth).verify_credentials
session['rtoken'] = session['rsecret'] = nil
session[:atoken] = oauth.access_token.token
session[:asecret] = oauth.access_token.secret
sign_in(profile)
redirect_back_or root_path
end
However, after I click the "twitter" button, I get this error:
401 Unauthorized
.../gems/oauth-0.3.6/lib/oauth/consumer.rb:200:in `token_request'
.../gems/oauth-0.3.6/lib/oauth/consumer.rb:128:in `get_request_token'
.../gems/twitter-0.9.2/lib/twitter/oauth.rb:32:in `request_token'
.../gems/twitter-0.9.2/lib/twitter/oauth.rb:25:in `set_callback_url'
app/controllers/twitter_sessions_controller.rb:7:in `create'
If I go to the finalize url, http://localhost:3000/twitter_sessions/finalize
, directly, I get this error:
Unknown action
No action responded to show. Actions: create, destroy, finalize, isLoggedInToBeta, login_required, and new
Any ideas? Thanks