2

I put the grant_type parameter in the request body as the documentation shows, but Microsoft Graph still complains that it's not there;

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'.

    }
);
AskYous
  • 4,332
  • 9
  • 46
  • 82

1 Answers1

5

I figured it out. I had to use form instead of body for the request node module.

AskYous
  • 4,332
  • 9
  • 46
  • 82