grant_type参数无效或缺少参数

box api error getting the access token: Invalid grant_type parameter or parameter missing

本文关键字:参数 无效 type grant      更新时间:2023-09-26

我试图获得一个访问令牌,并使用以下url POST HTTP请求和接收

{
  "error":"invalid_request",
  "error_description":"Invalid grant_type parameter or parameter missing"
} 

错误信息。不管我怎么努力。我是在收到代码后几秒钟发布的,所以我不认为代码可能是故障点。

文章https://api.box.com/oauth2/token?grant_type=authorization_code&代码= H23sCQmlzsEJSEyhKXj19yb1LWew9MPk&client_id = xyz& client_secret = 123

我做错了什么?

我想你可以尝试在请求正文中发送grant_type=...,而不是作为查询字符串。

下面是该特定请求的文档示例:

curl https://api.box.com/oauth2/token '
-d 'grant_type=authorization_code&code={your_code}&client_id={your_client_id}&client_secret={your_client_secret}' '
-X POST

我一直遇到同样的问题,John的解决方案起作用了。与获取访问代码时在url中包含参数不同,您需要将它们编码为POST数据。

我使用的是Chrome邮差插件,我在点击x-www-form-urlencoded按钮后,在较低的Key-Value字段输入参数。