cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
Announcements
Share your feedback on the Document Scanning Experience in the Dropbox App right here.

Dropbox API Support & Feedback

Find help with the Dropbox API from other developers.

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

How to get an access token and refresh token

How to get an access token and refresh token

Kentwt
New member | Level 2
Go to solution

I am encountering issues when trying to obtain an access token and refresh token.

I retrieved the access code from the following URL: https://www.dropbox.com/oauth2/authorize?client_id=<app key>&redirect_uri=<REDIRECT URL>&token_access_type=offline&response_type=code

I input the access code obtained from the above into <AUTHORIZATION_CODE> and executed it:

{
 "code": "<AUTHORIZATION_CODE>",
 "grant_type": "authorization_code",
 "redirect_uri": "<REDIRECT_URI>",
 "client_id": "<APP_KEY>",
 "client_secret": "<APP_SECRET>"

}

However, I received the following error:

There was an issue setting up your call.

Raw response for the API Status code 400
{"error": "invalid_request", "error_description": "The request parameters do not match any of the supported authorization flows. Please refer to the API documentation for the correct parameters."}


I am unsure of what needs to be corrected. Because this is not functioning correctly, I am unable to proceed with obtaining the refresh token.
I would appreciate your advice.

1 Accepted Solution

Accepted Solutions

Greg-DB
Dropbox Staff
Go to solution

When you say you executed it, it sounds like you're referring to the step where you call /oauth2/token to exchange the authorization code for a refresh token and access token. It looks you're sending the parameters as JSON though, but the /oauth2/token endpoint requires application/x-www-form-urlencoded POST parameters, not JSON. Please update your code to send those parameters as application/x-www-form-urlencoded POST parameters. There's an example of this flow here that may be helpful.

View solution in original post

2 Replies 2

Greg-DB
Dropbox Staff
Go to solution

When you say you executed it, it sounds like you're referring to the step where you call /oauth2/token to exchange the authorization code for a refresh token and access token. It looks you're sending the parameters as JSON though, but the /oauth2/token endpoint requires application/x-www-form-urlencoded POST parameters, not JSON. Please update your code to send those parameters as application/x-www-form-urlencoded POST parameters. There's an example of this flow here that may be helpful.

Kentwt
New member | Level 2
Go to solution

Thank you for your help. It is working properly now.

Need more support?
Who's talking

Top contributors to this post

  • User avatar
    Kentwt New member | Level 2
  • User avatar
    Greg-DB Dropbox Staff
What do Dropbox user levels mean?