【发布时间】:2014-07-30 06:43:45
【问题描述】:
我几乎尝试了所有方法,阅读了有关此问题的所有 StackOverflow 帖子,但我仍然无法使其正常工作。有趣的是,当通过 DHC REST API 客户端(Google Chrome 应用程序)发送 POST 请求时,我能够得到 200 OK 响应。
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);
});
【问题讨论】:
-
您将请求作为 POST 发送,但参数作为 GET。
-
@BenFortune /faceplam。我知道我在做一些愚蠢的事情。感谢您发现我的错误。
标签: node.js authentication oauth-2.0 google-oauth