Doesn't work with Twitter API 1.1 #132

Closed
gitbase opened this Issue Mar 7, 2013 · 6 comments

Projects

None yet

3 participants

@gitbase
gitbase commented Mar 7, 2013
oa.get("https://api.twitter.com/1.1/users/show.json?screen_name=rsarver", access_token, access_token_secret, function(error, data) {
  console.log(data);
});

Try that piece of code and you'll get - {"errors":[{"message":"Bad Authentication data","code":215}]}

@ciaranj
Owner
ciaranj commented Mar 7, 2013

Works for me, you sure you've setup everything correctly? .. The following code:

var OAuth= require('oauth').OAuth;

oa = new OAuth("https://api.twitter.com/oauth/request_token",
                 "https://api.twitter.com/oauth/access_token", 
                 "<CONSUMER_KEY>", "<CONSUMER_SECRET>", 
                 "1.0A", "http://localhost:3000/oauth/callback", "HMAC-SHA1");

var access_token= "<ACCESS_TOKEN>";
var access_token_secret= "<ACCESS_TOKEN_SECRET>";

oa.get("https://api.twitter.com/1.1/users/show.json?screen_name=rsarver", access_token, access_token_secret, function(error, data) {
  console.log(data);
})          

Provides the following results:

{"id":795649,"id_str":"795649","name":"Ryan Sarver","screen_name":"rsarver","location":"San Francisco, CA","description":"Director, Platform at Twitter. Detroit and Boston export. Foodie and over-the-hill hockey player. @devon's lesser half","url":null,"entities":{"description":{"urls":[]}},"protected":false,"followers_count":282170,"friends_count":2094,"listed_count":1652,"created_at":"Mon Feb 26 18:05:55 +0000 2007","favourites_count":8596,"utc_offset":-28800,"time_zone":"Pacific Time (US & Canada)","geo_enabled":true,"verified":false,"statuses_count":17286,"lang":"en","status":{"created_at":"Thu Mar 07 18:37:04 +0000 2013","id":309734460595765248,"id_str":"309734460595765248","text":"@kurrik I still haven't haven't heard a good response from you...","source":"\u003ca href="http://itunes.apple.com/us/app/twitter/id409789998?mt=12" rel="nofollow"\u003eTwitter for Mac\u003c/a\u003e","truncated":false,"in_reply_to_status_id":309734181234147328,"in_reply_to_status_id_str":"309734181234147328","in_reply_to_user_id":7588892,"in_reply_to_user_id_str":"7588892","in_reply_to_screen_name":"kurrik","geo":null,"coordinates":null,"place":null,"contributors":null,"retweet_count":0,"entities":{"hashtags":[],"urls":[],"user_mentions":[{"screen_name":"kurrik","name":"Arne Roomann-Kurrik","id":7588892,"id_str":"7588892","indices":[0,7]}]},"favorited":false,"retweeted":false,"lang":"en"},"contributors_enabled":true,"is_translator":false,"profile_background_color":"5A7073","profile_background_image_url":"http://a0.twimg.com/profile_background_images/674936752/2ea522d8c0a021d41a5af0556fc076fc.png","profile_background_image_url_https":"https://si0.twimg.com/profile_background_images/674936752/2ea522d8c0a021d41a5af0556fc076fc.png","profile_background_tile":true,"profile_image_url":"http://a0.twimg.com/profile_images/3015419114/3dc096c48ef6167d1b26fd0d6b01814d_normal.jpeg","profile_image_url_https":"https://si0.twimg.com/profile_images/3015419114/3dc096c48ef6167d1b26fd0d6b01814d_normal.jpeg","profile_banner_url":"https://si0.twimg.com/profile_banners/795649/1349880919","profile_link_color":"DE3737","profile_sidebar_border_color":"F5E5AE","profile_sidebar_fill_color":"EB7650","profile_text_color":"DE3737","profile_use_background_image":true,"default_profile":false,"default_profile_image":false,"following":false,"follow_request_sent":false,"notifications":false}

@ciaranj ciaranj closed this Mar 7, 2013
@gitbase
gitbase commented Mar 7, 2013

"1.0A" makes it work, shouldn't we use "1.1A" ? It represents the Twitter API Version right ?

@ciaranj
Owner
ciaranj commented Mar 7, 2013

Ah I see your confusion, no the 1.0A refers to the version of OAuth being
used, not the version of their API ;). Possibly they've become more strict
on requiring this string being sent with the new api requests ?

  • cj

On Thursday, March 7, 2013, gitbase wrote:

"1.0A" makes it work, shouldn't we use "1.1A" ? It represents the Twitter
API Version right ?


Reply to this email directly or view it on GitHubhttps://github.com/ciaranj/node-oauth/issues/132#issuecomment-14582746
.

@kurrik
kurrik commented Mar 7, 2013

Hey, hope you don't mind me replying but I was summoned to this bug via the response dump above :)

Technically "1.0" is the correct value to send, even for OAuth1.0a. There's a lot of discussion for background on the OAuth mailing list which is probably not worth going into. Twitter documents "1.0" as the correct value: https://dev.twitter.com/docs/auth/authorizing-request

That "1.0A" works is probably a convenience for clients which assume the version identifier was changed when 1.0a was released. I would expect "1.1A" to fail always.

The only Twitter API version identifier sent is in the path. Any OAuth client capable of sending a valid Twitter v1.0 request should be able to send v1.1 without modification. Aside from requiring auth, no auth implementation changes were made between those versions.

Hope that's useful! Thanks for the library!

@ciaranj
Owner
ciaranj commented Mar 7, 2013

@kurrik haha, sorry my bad I didn't even think of that, just grok'd it for email addresses! Sorry I didn't clarify it before, but yes 1.0 or 1.0A both work just fine for the provided request strings !

However seems very odd that someone has recently also raised: #131 which is painfully close to this issue!

@kurrik
kurrik commented Mar 7, 2013

We just did a blackout test for Twitter API v1.0 this week, so I think there are a lot of people looking into updating their integrations to 1.1. The OAuth identifier is unfortunately very similar to our API version.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment