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

好久不见. 提交于 2019-12-06 07:53:39

问题


I am trying to get an access token and using the following url to POST the HTTP request and receiving

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

error message . No matter what I try. I am posting seconds after receiving the code so I dont think the code could be the failure point.

post https://api.box.com/oauth2/token?grant_type=authorization_code&code=H23sCQmlzsEJSEyhKXj19yb1LWew9MPk&client_id=xyz&client_secret=123

What am I doing wrong?


回答1:


I think you might try sending the grant_type=... in the request body, not as a query string.

Here's the documentation example for that particular request:

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




回答2:


I had been having this same problem and John's solution worked. Instead of including the parameters in the url as you do when getting the access code, you need to encode them as POST data.

I'm using the Postman add-in for Chrome and I enter the parameters in the lower Key-Value fields after clicking the x-www-form-urlencoded button.



来源:https://stackoverflow.com/questions/14249648/box-api-error-getting-the-access-token-invalid-grant-type-parameter-or-paramete

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