[twitter-dev] Re: Problems with 2-legged access to Twitter using OAuth gem (ruby)
Hi Taylor, Thanks for the quick response. I stand corrected on the three-legged authentication. Skipping a few steps doesn't make it 2 :) You're right about the typo - the code I was using was incorrect. Having fixed it, however, didn't seem to help. Here's the response I'm getting (after the fix): - HTTP/1.1 401 Unauthorized\r\n - Date: Thu, 09 Sep 2010 19:25:23 GMT\r\n - Server: hi\r\n - Status: 401 Unauthorized\r\n - WWW-Authenticate: Basic realm=\Twitter API\\r\n - Content-Type: application/xml; charset=utf-8\r\n - Content-Length: 137\r\n - Cache-Control: no-cache, max-age=1800\r\n - Set-Cookie: k=71.183.40.72.1284060323860138; path=/; expires=Thu, 16-Sep-10 19:25:23 GMT; domain=.twitter.com\r\n - Set-Cookie: guest_id=128406032386923588; path=/; expires=Sat, 09 Oct 2010 19:25:23 GMT\r\n - Set-Cookie: _twitter_sess=BAh7BiIKZmxhc2hJQzonQWN0aW9uQ29udHJvbGxlcjo6Rmxhc2g6OkZsYXNo %250ASGFzaHsABjoKQHVzZWR7AA%253D %253D--1164b91ac812d853b877e93ddb612b7471bebc74; domain=.twitter.com; path=/\r\n - Expires: Thu, 09 Sep 2010 19:55:23 GMT\r\n - Vary: Accept-Encoding\r\n - Connection: close\r\n - \r\n The new code is now: consumer = OAuth::Consumer.new(KEY, SECRET, { :site = http:// api.twitter.com, :scheme = :header }) token_hash = { :oauth_token = OTHER KEY, :oauth_token_secret = OTHER SECRET} access_token = OAuth::AccessToken.from_hash(consumer, token_hash) res = access_token.get(/statuses/update.xml, {status = Hello tweet}) Any thoughts? thanks, Eran On Sep 9, 1:37 pm, Taylor Singletary taylorsinglet...@twitter.com wrote: 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
Re: [twitter-dev] Re: Problems with 2-legged access to Twitter using OAuth gem (ruby)
Invalid/Expired token says it all.. Tom On 9/9/10 11:00 PM, EranD wrote: Thanks for the help. Unfortunately I've already tried all of those :( res = access_token.post(/1/statuses/update.xml, {status = Hello tweet}) response is the same: HTTP/1.1 401 Unauthorized\r\n - Date: Thu, 09 Sep 2010 20:58:01 GMT\r\n - Server: hi\r\n - Status: 401 Unauthorized\r\n - WWW-Authenticate: Basic realm=\Twitter API\\r\n - Content-Type: application/xml; charset=utf-8\r\n - Content-Length: 139\r\n - Cache-Control: no-cache, max-age=1800\r\n - Set-Cookie: k=71.183.40.72.1284065880883182; path=/; expires=Thu, 16-Sep-10 20:58:00 GMT; domain=.twitter.com\r\n - Set-Cookie: guest_id=128406588098859508; path=/; expires=Sat, 09 Oct 2010 20:58:00 GMT\r\n - Set-Cookie: _twitter_sess=BAh7BiIKZmxhc2hJQzonQWN0aW9uQ29udHJvbGxlcjo6Rmxhc2g6OkZsYXNo %250ASGFzaHsABjoKQHVzZWR7AA%253D %253D--1164b91ac812d853b877e93ddb612b7471bebc74; domain=.twitter.com; path=/\r\n - Expires: Thu, 09 Sep 2010 21:28:00 GMT\r\n - Vary: Accept-Encoding\r\n - Connection: close\r\n - \r\n reading 139 bytes... - ?xml version=\1.0\ encoding=\UTF-8\?\nhash\n request/1/ statuses/update.xml/request\n errorInvalid / expired Token/error \n/hash\n Any other thoughts? On Sep 9, 3:37 pm, Taylor Singletary taylorsinglet...@twitter.com wrote: Happy to help further: The line access_token.get(/statuses/update.xml has two problems... 1. should have the version slug added in.. /1/statuses/update.xml 2. creating a status update requires the POST HTTP method (as opposed to GET) You're very close, provided everything else is working correctly. Taylor On Thu, Sep 9, 2010 at 12:30 PM, EranD eran.davi...@gmail.com wrote: Hi Taylor, Thanks for the quick response. I stand corrected on the three-legged authentication. Skipping a few steps doesn't make it 2 :) You're right about the typo - the code I was using was incorrect. Having fixed it, however, didn't seem to help. Here's the response I'm getting (after the fix): - HTTP/1.1 401 Unauthorized\r\n - Date: Thu, 09 Sep 2010 19:25:23 GMT\r\n - Server: hi\r\n - Status: 401 Unauthorized\r\n - WWW-Authenticate: Basic realm=\Twitter API\\r\n - Content-Type: application/xml; charset=utf-8\r\n - Content-Length: 137\r\n - Cache-Control: no-cache, max-age=1800\r\n - Set-Cookie: k=71.183.40.72.1284060323860138; path=/; expires=Thu, 16-Sep-10 19:25:23 GMT; domain=.twitter.com\r\n - Set-Cookie: guest_id=128406032386923588; path=/; expires=Sat, 09 Oct 2010 19:25:23 GMT\r\n - Set-Cookie: _twitter_sess=BAh7BiIKZmxhc2hJQzonQWN0aW9uQ29udHJvbGxlcjo6Rmxhc2g6OkZsYXNo %250ASGFzaHsABjoKQHVzZWR7AA%253D %253D--1164b91ac812d853b877e93ddb612b7471bebc74; domain=.twitter.com; path=/\r\n - Expires: Thu, 09 Sep 2010 19:55:23 GMT\r\n - Vary: Accept-Encoding\r\n - Connection: close\r\n - \r\n The new code is now: consumer = OAuth::Consumer.new(KEY, SECRET, { :site = http:// api.twitter.com, :scheme = :header }) token_hash = { :oauth_token = OTHER KEY, :oauth_token_secret = OTHER SECRET} access_token = OAuth::AccessToken.from_hash(consumer, token_hash) res = access_token.get(/statuses/update.xml, {status = Hello tweet}) Any thoughts? thanks, Eran On Sep 9, 1:37 pm, Taylor Singletary taylorsinglet...@twitter.com wrote: 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 =
[twitter-dev] Re: Problems with 2-legged access to Twitter using OAuth gem (ruby)
Very strange. The token and access keys were all created yesterday by twitter. Swithcing to gem 0.3.6 didn't help either. On Sep 9, 5:08 pm, Tom van der Woerdt i...@tvdw.eu wrote: Invalid/Expired token says it all.. Tom On 9/9/10 11:00 PM, EranD wrote: Thanks for the help. Unfortunately I've already tried all of those :( res = access_token.post(/1/statuses/update.xml, {status = Hello tweet}) response is the same: HTTP/1.1 401 Unauthorized\r\n - Date: Thu, 09 Sep 2010 20:58:01 GMT\r\n - Server: hi\r\n - Status: 401 Unauthorized\r\n - WWW-Authenticate: Basic realm=\Twitter API\\r\n - Content-Type: application/xml; charset=utf-8\r\n - Content-Length: 139\r\n - Cache-Control: no-cache, max-age=1800\r\n - Set-Cookie: k=71.183.40.72.1284065880883182; path=/; expires=Thu, 16-Sep-10 20:58:00 GMT; domain=.twitter.com\r\n - Set-Cookie: guest_id=128406588098859508; path=/; expires=Sat, 09 Oct 2010 20:58:00 GMT\r\n - Set-Cookie: _twitter_sess=BAh7BiIKZmxhc2hJQzonQWN0aW9uQ29udHJvbGxlcjo6Rmxhc2g6OkZsYXNo %250ASGFzaHsABjoKQHVzZWR7AA%253D %253D--1164b91ac812d853b877e93ddb612b7471bebc74; domain=.twitter.com; path=/\r\n - Expires: Thu, 09 Sep 2010 21:28:00 GMT\r\n - Vary: Accept-Encoding\r\n - Connection: close\r\n - \r\n reading 139 bytes... - ?xml version=\1.0\ encoding=\UTF-8\?\nhash\n request/1/ statuses/update.xml/request\n errorInvalid / expired Token/error \n/hash\n Any other thoughts? On Sep 9, 3:37 pm, Taylor Singletary taylorsinglet...@twitter.com wrote: Happy to help further: The line access_token.get(/statuses/update.xml has two problems... 1. should have the version slug added in.. /1/statuses/update.xml 2. creating a status update requires the POST HTTP method (as opposed to GET) You're very close, provided everything else is working correctly. Taylor On Thu, Sep 9, 2010 at 12:30 PM, EranD eran.davi...@gmail.com wrote: Hi Taylor, Thanks for the quick response. I stand corrected on the three-legged authentication. Skipping a few steps doesn't make it 2 :) You're right about the typo - the code I was using was incorrect. Having fixed it, however, didn't seem to help. Here's the response I'm getting (after the fix): - HTTP/1.1 401 Unauthorized\r\n - Date: Thu, 09 Sep 2010 19:25:23 GMT\r\n - Server: hi\r\n - Status: 401 Unauthorized\r\n - WWW-Authenticate: Basic realm=\Twitter API\\r\n - Content-Type: application/xml; charset=utf-8\r\n - Content-Length: 137\r\n - Cache-Control: no-cache, max-age=1800\r\n - Set-Cookie: k=71.183.40.72.1284060323860138; path=/; expires=Thu, 16-Sep-10 19:25:23 GMT; domain=.twitter.com\r\n - Set-Cookie: guest_id=128406032386923588; path=/; expires=Sat, 09 Oct 2010 19:25:23 GMT\r\n - Set-Cookie: _twitter_sess=BAh7BiIKZmxhc2hJQzonQWN0aW9uQ29udHJvbGxlcjo6Rmxhc2g6OkZsYXNo %250ASGFzaHsABjoKQHVzZWR7AA%253D %253D--1164b91ac812d853b877e93ddb612b7471bebc74; domain=.twitter.com; path=/\r\n - Expires: Thu, 09 Sep 2010 19:55:23 GMT\r\n - Vary: Accept-Encoding\r\n - Connection: close\r\n - \r\n The new code is now: consumer = OAuth::Consumer.new(KEY, SECRET, { :site = http:// api.twitter.com, :scheme = :header }) token_hash = { :oauth_token = OTHER KEY, :oauth_token_secret = OTHER SECRET} access_token = OAuth::AccessToken.from_hash(consumer, token_hash) res = access_token.get(/statuses/update.xml, {status = Hello tweet}) Any thoughts? thanks, Eran On Sep 9, 1:37 pm, Taylor Singletary taylorsinglet...@twitter.com wrote: 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?
[twitter-dev] Re: Problems with 2-legged access to Twitter using OAuth gem (ruby)
Very strange. The tokens and keys were generated by Twitter yesterday and still seem to be valid in the app interface. Switching to gem v0.3.6 did not help. On Sep 9, 5:08 pm, Tom van der Woerdt i...@tvdw.eu wrote: Invalid/Expired token says it all.. Tom On 9/9/10 11:00 PM, EranD wrote: Thanks for the help. Unfortunately I've already tried all of those :( res = access_token.post(/1/statuses/update.xml, {status = Hello tweet}) response is the same: HTTP/1.1 401 Unauthorized\r\n - Date: Thu, 09 Sep 2010 20:58:01 GMT\r\n - Server: hi\r\n - Status: 401 Unauthorized\r\n - WWW-Authenticate: Basic realm=\Twitter API\\r\n - Content-Type: application/xml; charset=utf-8\r\n - Content-Length: 139\r\n - Cache-Control: no-cache, max-age=1800\r\n - Set-Cookie: k=71.183.40.72.1284065880883182; path=/; expires=Thu, 16-Sep-10 20:58:00 GMT; domain=.twitter.com\r\n - Set-Cookie: guest_id=128406588098859508; path=/; expires=Sat, 09 Oct 2010 20:58:00 GMT\r\n - Set-Cookie: _twitter_sess=BAh7BiIKZmxhc2hJQzonQWN0aW9uQ29udHJvbGxlcjo6Rmxhc2g6OkZsYXNo %250ASGFzaHsABjoKQHVzZWR7AA%253D %253D--1164b91ac812d853b877e93ddb612b7471bebc74; domain=.twitter.com; path=/\r\n - Expires: Thu, 09 Sep 2010 21:28:00 GMT\r\n - Vary: Accept-Encoding\r\n - Connection: close\r\n - \r\n reading 139 bytes... - ?xml version=\1.0\ encoding=\UTF-8\?\nhash\n request/1/ statuses/update.xml/request\n errorInvalid / expired Token/error \n/hash\n Any other thoughts? On Sep 9, 3:37 pm, Taylor Singletary taylorsinglet...@twitter.com wrote: Happy to help further: The line access_token.get(/statuses/update.xml has two problems... 1. should have the version slug added in.. /1/statuses/update.xml 2. creating a status update requires the POST HTTP method (as opposed to GET) You're very close, provided everything else is working correctly. Taylor On Thu, Sep 9, 2010 at 12:30 PM, EranD eran.davi...@gmail.com wrote: Hi Taylor, Thanks for the quick response. I stand corrected on the three-legged authentication. Skipping a few steps doesn't make it 2 :) You're right about the typo - the code I was using was incorrect. Having fixed it, however, didn't seem to help. Here's the response I'm getting (after the fix): - HTTP/1.1 401 Unauthorized\r\n - Date: Thu, 09 Sep 2010 19:25:23 GMT\r\n - Server: hi\r\n - Status: 401 Unauthorized\r\n - WWW-Authenticate: Basic realm=\Twitter API\\r\n - Content-Type: application/xml; charset=utf-8\r\n - Content-Length: 137\r\n - Cache-Control: no-cache, max-age=1800\r\n - Set-Cookie: k=71.183.40.72.1284060323860138; path=/; expires=Thu, 16-Sep-10 19:25:23 GMT; domain=.twitter.com\r\n - Set-Cookie: guest_id=128406032386923588; path=/; expires=Sat, 09 Oct 2010 19:25:23 GMT\r\n - Set-Cookie: _twitter_sess=BAh7BiIKZmxhc2hJQzonQWN0aW9uQ29udHJvbGxlcjo6Rmxhc2g6OkZsYXNo %250ASGFzaHsABjoKQHVzZWR7AA%253D %253D--1164b91ac812d853b877e93ddb612b7471bebc74; domain=.twitter.com; path=/\r\n - Expires: Thu, 09 Sep 2010 19:55:23 GMT\r\n - Vary: Accept-Encoding\r\n - Connection: close\r\n - \r\n The new code is now: consumer = OAuth::Consumer.new(KEY, SECRET, { :site = http:// api.twitter.com, :scheme = :header }) token_hash = { :oauth_token = OTHER KEY, :oauth_token_secret = OTHER SECRET} access_token = OAuth::AccessToken.from_hash(consumer, token_hash) res = access_token.get(/statuses/update.xml, {status = Hello tweet}) Any thoughts? thanks, Eran On Sep 9, 1:37 pm, Taylor Singletary taylorsinglet...@twitter.com wrote: 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.