Created
March 20, 2011 06:20
-
-
Save kryali/878154 to your computer and use it in GitHub Desktop.
Sending a post request through node
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
payload = 'client_id='+client_id + '&client_secret='+ client_secret | |
+ '&code='+ code | |
var options = { | |
host: 'github.com', | |
path: '/login/oauth/access_token', | |
method: 'POST' | |
}; | |
var access_req = https.request(options, function(response){ | |
response.on('error', function(){ | |
console.log("Got an error!"); | |
}); | |
console.log(response.statusCode); | |
response.on('data', function(chunk){ | |
console.log(chunk.toString()); | |
res.send("(Hopefully) Posted access exchange to github " + chunk.toString()); | |
}); | |
}); | |
access_req.write(payload); | |
access_req.end(); | |
console.log("Sent the payload " + payload + "\n"); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment