Skip to content

Instantly share code, notes, and snippets.

@kryali
Created March 20, 2011 06:20
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kryali/878154 to your computer and use it in GitHub Desktop.
Save kryali/878154 to your computer and use it in GitHub Desktop.
Sending a post request through node
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