gpt4 book ai didi

oauth-2.0 - 框 oauth2 : Invalid grant_type parameter or parameter missing

转载 作者:行者123 更新时间:2023-12-04 10:01:05 25 4
gpt4 key购买 nike

我不知道我做错了什么,但是每次我尝试获取 token 时(当然是在用户身份验证之后),结果总是无效的 grant_type 参数或参数丢失

可能与Box API always returns invalid grant_type parameter on obtaining access token有关

这是我的 fiddle 手结果:

POST https://api.box.com/oauth2/token HTTP/1.1
Host: api.box.com
Content-Length: 157
Expect: 100-continue
Connection: Keep-Alive

grant_type=authorization_code&code=nnqtYcoik7cjtHQYyn3Af8uk4LG3rYYh&client_id=[myclientId]&client_secret=[mysecret]

结果:
HTTP/1.1 400 Bad Request
Server: nginx
Date: Thu, 07 Mar 2013 11:18:36 GMT
Content-Type: application/json
Connection: keep-alive
Set-Cookie: box_visitor_id=5138778bf12a01.27393131; expires=Fri, 07-Mar-2014 11:18:35 GMT; path=/; domain=.box.com
Set-Cookie: country_code=US; expires=Mon, 06-May-2013 11:18:36 GMT; path=/
Cache-Control: no-store
Content-Length: 99

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

即使遵循 curl 示例也会给出相同的错误。任何帮助,将不胜感激。

编辑:尝试使用额外的 redirect_uri 参数,但仍然是同样的错误
POST https://api.box.com/oauth2/token HTTP/1.1
Content-Type: application/json; charset=UTF-8
Host: api.box.com
Content-Length: 187
Expect: 100-continue
Connection: Keep-Alive

grant_type=authorization_code&code=R3JxS7UPm8Gjc0y7YLj9qxifdzBYzLOZ&client_id=*****&client_secret=*****&redirect_uri=http://localhost

结果:
HTTP/1.1 400 Bad Request
Server: nginx
Date: Sat, 09 Mar 2013 00:46:38 GMT
Content-Type: application/json
Connection: keep-alive
Set-Cookie: box_visitor_id=513a866ec5cfe0.48604831; expires=Sun, 09-Mar-2014 00:46:38 GMT; path=/; domain=.box.com
Set-Cookie: country_code=US; expires=Wed, 08-May-2013 00:46:38 GMT; path=/
Cache-Control: no-store
Content-Length: 99

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

最佳答案

看起来 Box 需要正确的 Content-Type: application/x-www-form-urlencoded请求头以及正确的 URL 编码参数。这似乎同样适用于刷新和撤销请求。

此外,根据 RFC 6749 , redirect_uri只是

REQUIRED, if the "redirect_uri" parameter was included in the authorization request as described in Section 4.1.1, and their values MUST be identical.

关于oauth-2.0 - 框 oauth2 : Invalid grant_type parameter or parameter missing,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15269989/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com