Created
February 5, 2014 19:44
-
-
Save Sneagan/8831511 to your computer and use it in GitHub Desktop.
ADN Authorization Code POST Request
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
app.get('/success', function(req, res){ | |
var postFunction = function(reqq) { | |
var access_token = reqq.query.code; | |
var post_data = querystring.stringify({ | |
'client_id': 'client_id', | |
'client_secret': 'client_secret', | |
'grant_type': 'authorization_code', | |
'redirect_uri': 'http://127.0.0.1:3000/', | |
'code': access_token | |
}); | |
var options = { | |
url: 'https://account.app.net/oauth/access_token?' + post_data, | |
headers: { | |
'Content-Type': 'application/x-www-form-urlencoded', | |
'Content-Length': post_data.length | |
} | |
}; | |
var callback = function(error, response, body) { | |
console.log(body); | |
if (!error && response.statusCode == 200) { | |
var info = JSON.parse(body); | |
} | |
}; | |
request.post(options, callback); | |
}; | |
res.render('success', {}, postFunction(req)); | |
}) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Ah, got it. You're sending the parameters as part of the URL, instead of the request body. It looks like you're using the request library, so the solution is quite simple: