I am trying to get the access key but I cannot make it work. “request_token.get_access_tokenis giving me401 Unauthorized (OAuth::Unauthorized)error. I copy the authorize_url into my browser, allow the application, I receive some kind of PIN from twitter but after hitting enter in my script I always get 401 error. I did some search and I found this helpedaccess_token = request_token.get_access_token(:oauth_verifier => params[:oauth_verifier])but it is giving meundefined local variable or method params' for main:Object (NameError)
- the twitter application type is client
- the ruby script is like ( I was following this tutorial )
- I’d love to get out of this scrip access details. The best without using PIN.
.
gem 'oauth'
require 'oauth/consumer'
consumer_key = 'your key'
consumer_secret ='your secret'
consumer=OAuth::Consumer.new "consumer_key",
"consumer_secret",
{:site=>"http://twitter.com"}
request_token = consumer.get_request_token
puts request_token.token
puts request_token.secret
puts request_token.authorize_url
puts "Hit enter when you have completed authorization."
STDIN.gets
access_token = request_token.get_access_token
#access_token = request_token.get_access_token(:oauth_verifier => params[:oauth_verifier])
puts access_token.token
puts access_token.secret
puts
puts access_token.inspect
I was having the exact same problem.
replace:
with:
The to_i converts to integer which also acts to strip whitespace.
Then you need to specify the pin when trying to get the acess token. If you do not do this there is no proof that the user has allowed your application.