Twitter4R 0.5.0 OAuth Goodness => Helplessness

14 views
Skip to first unread message

Steve

unread,
Sep 3, 2010, 1:01:40 AM9/3/10
to twitter4r-users
HELP! I feel so helpless trying to do something that I'd think should
be so simple. What is wrong with the following code?!

require 'rubygems'
gem 'twitter4r', '0.5.0'
require 'twitter'
require 'twitter/console'

client = Twitter::Client.new(
:oauth_consumer => {
:key => "consumer-key",
:secret => "consumer-secret"
},
:oauth_access => {
:key => "access-token",
:secret => "access-key"
},
:login => "myscreenname")

# Looks ok
puts client.inspect

# Works fine: shows screen names of some followers
client.user('someone', :followers, :count => 5).each do |f|
puts f.screen_name
end

# Fails with "raise_rest_error: Unauthorized (Twitter::RESTError)"
client.status(:post, 'Test steve')


The full text of the error follows:

/usr/local/lib/ruby/gems/1.8/gems/twitter4r-0.5.0/lib/twitter/client/
base.rb:92:in `raise_rest_error': Unauthorized (Twitter::RESTError)
from /usr/local/lib/ruby/gems/1.8/gems/twitter4r-0.5.0/lib/twitter/
client/base.rb:97:in `handle_rest_response'
from /usr/local/lib/ruby/gems/1.8/gems/twitter4r-0.5.0/lib/twitter/
client/base.rb:23:in `rest_oauth_connect'
from /usr/local/lib/ruby/gems/1.8/gems/twitter4r-0.5.0/lib/twitter/
client/status.rb:42:in `status'
from twitest.rb:22

Thoughts? I am at my wits end with this...

Thanks,
Steve

SP

unread,
Sep 3, 2010, 12:44:12 PM9/3/10
to twitter4r-users
Steve,

In this case it *might* be that you have granted only read-only access
to the application. Can you check that? There are two modes of
access: read-only and read-write for users to grant to different
applications. I only say that this might be the case because you
appear to be able to read from the Twitter.com API without any errors,
but failing on a write.

Let me know if that is the problem or not for reference and to help
others that might have the same problem on the mailing list.

Best,
Susan

Steve

unread,
Sep 3, 2010, 6:08:17 PM9/3/10
to twitter4r-users
Hi Susan, it is correctly set to Read and Write...

Steve

unread,
Sep 3, 2010, 11:33:54 PM9/3/10
to twitter4r-users
As mentioned in another thread, changing :key and :secret to strings
makes everything work perfectly!

Steve
Reply all
Reply to author
Forward
0 new messages