Christen Mitchell
Christen Mitchell

Reputation: 31

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

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?

Upvotes: 3

Views: 3962

Answers (2)

geekly
geekly

Reputation: 678

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.

Upvotes: 1

John Hoerr
John Hoerr

Reputation: 8035

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

Upvotes: 5

Related Questions