我将grant_type
参数放在文档正文中的请求正文中,但是Microsoft Graph仍然抱怨它不存在;
const tokenRequestBody = [
"grant_type=client_credentials",
"scope=https%3A%2F%2Fgraph.microsoft.com%2F.default",
`client_secret=${config.appClient.password}`
].join("&");
request.post(
{
url: tokenRequestUrl,
json: true,
headers: {
"content-type": "application/application/x-www-form-urlencoded"
},
body: tokenRequestBody
},
(err, req, body) => {
console.log(body.error_description);
// Logs: The request body must contain the following parameter: 'grant_type'.
}
);
答案 0 :(得分:1)
我知道了。对于请求节点模块,我必须使用form
而不是body
。