BotBuilder, Direct Line API returns “tokenParameters is missing User” with Enhanced authentication options

三世轮回 提交于 2019-12-06 12:53:20

It looks like you are missing the Content-Type in your header. Take a look at the code snippet below.

try {
  const res = await fetch('https://directline.botframework.com/v3/directline/tokens/generate', 
    { 
      method: 'POST',
      headers: {
        'Authorization': `Bearer <SECRET>`,
        'Content-Type': 'application/json'
      },
      body: {
        user: { 
          id: "dl_123", // user id must start with 'dl_'
          name: "user" 
        }
      }
    });

    const json = await res.json();

} catch (error) {
  console.log(error)
}

Note, you shouldn't have to check is 'error' is in the JSON response - the try-catch block should take care of that.

Hope this helps!

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!