I have tried just about everything, read every StackOverflow post on this issue but I still can't get it to work. Interestingly enough, I am able to get 200 OK response when sending a POST request via DHC REST API Client (Google Chrome app).
var url = 'https://accounts.google.com/o/oauth2/token';
var params = querystring.stringify({
grant_type: 'authorization_code',
code: req.body.code,
client_id: req.body.clientId,
client_secret: 'HIDDEN',
redirect_uri: req.body.redirectUri
});
params = querystring.unescape(params); // doesn't work with or without string escaping
request.post(url + '?' + params, function(error, response, body) {
console.log(body);
});
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…