I was looking for how to accurately use the oauthable module in the Devise stone for Rails 3. I came across a few questions here that seem correct, but I could not get the implementation to work. My ultimate goal is to have Twitter and Facebook authenticated through Devise in my Rails 3 app. Right now I'm struggling with what I thought was an “example” in the security strategy list. I got it far.
Inside my recycling activator, I have the following blocks of code, which I believe in, in the appropriate places.
manager.oauth(:twitter) do |twitter|
twitter.consumer_secret = '[secret]'
twitter.consumer_key = '[key]'
twitter.options :site => 'http://twitter.com'
end
manager.default_strategies(:scope => :user).unshift :twitter_oauth
Warden::OAuth::access_token_user_finder(:twitter) do |access_token|
User.find_or_create_by(:token => access_token.token, :secret => access_token.secret).tap do |user|
user ||= User.create!(:access_token => access_token.token, :secret => access_token.secret)
end
end
I put a link to one of my views, but all I get is a mistake, OAuth 401 Unauthorized, is it something from Twitter or did I completely skip the step?