添加链接
link之家
链接快照平台
  • 输入网页链接,自动生成快照
  • 标签化管理网页链接
Collectives™ on Stack Overflow

Find centralized, trusted content and collaborate around the technologies you use most.

Learn more about Collectives

Teams

Q&A for work

Connect and share knowledge within a single location that is structured and easy to search.

Learn more about Teams

The request body must contain the following parameter: 'grant_type'... but I put it in the body

Ask Question

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

Thanks for contributing an answer to Stack Overflow!

  • Please be sure to answer the question. Provide details and share your research!

But avoid

  • Asking for help, clarification, or responding to other answers.
  • Making statements based on opinion; back them up with references or personal experience.

To learn more, see our tips on writing great answers.