1
votes

I am using OAuth 2.0 for Authorization process.

I have requested for Authorization Code with this url:

https://www.box.com/api/oauth2/authorize?response_type=code&client_id={MY_CLIENT_ID}

Then I was redirected to box.net login page for authorization.

I have entered credentials for my Box.net account. Granted access for account.Then I got Authorization code which I encoded in URL and sent a request with this:

https://www.box.com/api/oauth2/token?grant_type=authorization_code&code={AUTHORIZATION_CODE}&client_id={MY_CLIENT_ID}&client_secret={MY_CLIENT_SECRET_ID}

I got this response:

{"error":"invalid_client","error_description":"The client credentials are invalid"}

I have checked my Client Id and Client Secret Id many times. Those are correct. What can be reason for such an error message?

1

1 Answers

2
votes

As the official documentation states:

To get the access_token, you’ll need to make a POST request to https://www.box.com/api/oauth2/token with the following parameters...",

Although all the parameters including client_id, client_secret, grant_type and code are right, if you don't make a POST request to the url, you will get error: "invalid_client".

Try:

curl https://www.box.com/api/oauth2/token \
-d 'grant_type=authorization_code&code={your code}&client_id={your client id}&client_secret={your client secret}' \
-X POST