Skip to content

Instantly share code, notes, and snippets.

@ivanvs
Last active February 13, 2018 14:48
Show Gist options
  • Save ivanvs/e6bce5264bd3e9163ab10b2470c04274 to your computer and use it in GitHub Desktop.
Save ivanvs/e6bce5264bd3e9163ab10b2470c04274 to your computer and use it in GitHub Desktop.
React example how to do authenitcation with Twitter
router.route('/auth/twitter/reverse')
.post(function(req, res) {
request.post({
url: 'https://api.twitter.com/oauth/request_token',
oauth: {
oauth_callback: "http%3A%2F%2Flocalhost%3A3000%2Ftwitter-callback",
consumer_key: 'KEY',
consumer_secret: 'SECRET'
}
}, function (err, r, body) {
if (err) {
return res.send(500, { message: err.message });
}
var jsonStr = '{ "' + body.replace(/&/g, '", "').replace(/=/g, '": "') + '"}';
res.send(JSON.parse(jsonStr));
});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment