Created
January 14, 2014 10:42
-
-
Save csrui/8416438 to your computer and use it in GitHub Desktop.
OAuth requests with library Unirest.io
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var Request = unirest.get('https://api.twitter.com/oauth/request_token'); | |
Request.oauth({ | |
callback: 'http://mysite.com/callback/' | |
, consumer_key: 'CONSUMER_KEY' | |
, consumer_secret: 'CONSUMER_SECRET' | |
}).end(function (response) { | |
var access_token = response.body; | |
Request = unirest.post('https://api.twitter.com/oauth/access_token'); | |
Request.oauth({ | |
consumer_key: 'CONSUMER_KEY' | |
, consumer_secret: 'CONSUMER_SECRET' | |
, token: access_token.oauth_token | |
, verifier: token: access_token.oauth_verifier | |
}).end(function (response) { | |
var token = response.body; | |
Request = unirest.get('https://api.twitter.com/1/users/show.json'); | |
Request.oauth({ | |
consumer_key: 'CONSUMER_KEY' | |
, consumer_secret: 'CONSUMER_SECRET' | |
, token: token.oauth_token | |
, token_secret: token.oauth_token_secret | |
}).query({ | |
screen_name: token.screen_name | |
, user_id: token.user_id | |
}).end(function (response) { | |
console.log(response.body); | |
}); | |
}) | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment