[twitter-dev] Problems with 2-legged access to Twitter using OAuth gem (ruby)

2010-09-09 Thread EranD
Hi,

I'm trying to get a server app to tweet messages to one specific
account I own. I'm following Twitter's instructions on Twitter's wiki:
http://developer.twitter.com/pages/oauth_single_token#ruby

I can read information from twitter (e.g. get last 20 tweets), but
when I try to update my status I get the error Could not authenticate
with OAuth in the body of the 401 response.

The simplified code I'm using is below. Key , secret, access token and
secret are all copied from my twitter application page on
developer.twitter.com. OAuth gem version 0.4.3.

Any thoughts or suggestions?

--
consumer = OAuth::Consumer.new(MY KEY, MY SECRET, { :site =
http://api.twitter.com;, :scheme = :header })

token_hash = { :oath_token = MY ACCESS TOKEN, :oauth_token_secret
= MY ACCESS SECRET}
access_token = OAuth::AccessToken.from_hash(consumer, token_hash)

res = access_token.get(/statuses/update.xml, {status = Hello
tweet})
-


Response:
Net::HTTPUnauthorized 401 Unauthorized readbody=true


thanks,

Eran

-- 
Twitter developer documentation and resources: http://dev.twitter.com/doc
API updates via Twitter: http://twitter.com/twitterapi
Issues/Enhancements Tracker: http://code.google.com/p/twitter-api/issues/list
Change your membership to this group: 
http://groups.google.com/group/twitter-development-talk?hl=en


Re: [twitter-dev] Problems with 2-legged access to Twitter using OAuth gem (ruby)

2010-09-09 Thread Taylor Singletary
Hi Eran,

First, just a clarification of terms: this isn't technically 2-legged
OAuth, this is still three-legged.

The code you've pasted here has a mis-spelled key name for :oauth_token
(you've provided oath_token -- is this true of the code you are executing
as well?

I haven't personally tested the 0.4.3 version of the Ruby gem, but have had
ongoing affection for version 0.3.6 for some time.

Finally, the error message you are getting back from Twitter is actually
more detailed than what you see in the default exception raising of the
OAuth gem. You'll need to take a look at the raw body response we send you
for more information on why this error might be occurring.

Thanks,
Taylor

On Thu, Sep 9, 2010 at 10:19 AM, EranD eran.davi...@gmail.com wrote:

 Hi,

 I'm trying to get a server app to tweet messages to one specific
 account I own. I'm following Twitter's instructions on Twitter's wiki:
 http://developer.twitter.com/pages/oauth_single_token#ruby

 I can read information from twitter (e.g. get last 20 tweets), but
 when I try to update my status I get the error Could not authenticate
 with OAuth in the body of the 401 response.

 The simplified code I'm using is below. Key , secret, access token and
 secret are all copied from my twitter application page on
 developer.twitter.com. OAuth gem version 0.4.3.

 Any thoughts or suggestions?

 --
 consumer = OAuth::Consumer.new(MY KEY, MY SECRET, { :site =
 http://api.twitter.com;, :scheme = :header })

 token_hash = { :oath_token = MY ACCESS TOKEN, :oauth_token_secret
 = MY ACCESS SECRET}
 access_token = OAuth::AccessToken.from_hash(consumer, token_hash)

 res = access_token.get(/statuses/update.xml, {status = Hello
 tweet})
 -


 Response:
 Net::HTTPUnauthorized 401 Unauthorized readbody=true


 thanks,

 Eran

 --
 Twitter developer documentation and resources: http://dev.twitter.com/doc
 API updates via Twitter: http://twitter.com/twitterapi
 Issues/Enhancements Tracker:
 http://code.google.com/p/twitter-api/issues/list
 Change your membership to this group:
 http://groups.google.com/group/twitter-development-talk?hl=en


-- 
Twitter developer documentation and resources: http://dev.twitter.com/doc
API updates via Twitter: http://twitter.com/twitterapi
Issues/Enhancements Tracker: http://code.google.com/p/twitter-api/issues/list
Change your membership to this group: 
http://groups.google.com/group/twitter-development-talk?hl=en