Last active
February 13, 2018 14:48
-
-
Save ivanvs/e6bce5264bd3e9163ab10b2470c04274 to your computer and use it in GitHub Desktop.
React example how to do authenitcation with Twitter
This file contains 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
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