cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
Announcements
What’s new: end-to-end encryption, Replay and Dash updates. Find out more about these updates, new features and more 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: 

Re: Oauth2 refresh token question - what happens when the refresh token expires?

Re: Oauth2 refresh token question - what happens when the refresh token expires?

divyesh
Explorer | Level 4

When I'm trying to fetch short-lived access token I'm getting this error 

 

Client error: `POST https://api.dropbox.com/oauth2/token` resulted in a 400 Bad Request response: {"error_description": "missing required field \"grant_type\"", "error": "unsupported_grant_type"}
 
 
7 Replies 7

Greg-DB
Dropbox Staff

Can you share the code you're using that produces this error? Based on the error message, it sounds like you're not supplying the "grant_type" parameter when calling the /oauth2/token endpoint. That "grant_type" parameter should be set to either "authorization_code", when exchanging an authorization code for an access token and optionally a refresh token, or "refresh_token" when using a refresh token to get a new short-lived access token.

divyesh
Explorer | Level 4

Hello

 

Thanks for your reply

 

I have resolved an error and also get the access token which was needed but that one is not working.

 

I have used this link token for testing and it's working fine and it it oauth1 

https://dropbox.github.io/dropbox-api-v2-explorer/#auth_token/from_oauth1

Access Token : sl.A6K<REDACTED>

 

I need Oauth2 access token, How to get that token?

 

Thanks in advance.

Greg-DB
Dropbox Staff

The access token you posted, which starts with "sl.", is a Dropbox OAuth 2 access token. Note that you should never post these publicly though, so please refrain from doing so in the future.

 

The "sl." prefix indicates that this particular access token is a "short-lived" access token, meaning that it was only valid for four hours, after which it can no longer be used to successfully perform Dropbox API calls. When a short-lived access token like this expires, if you need to make further calls, you would need to get a new one. You would do so either by using a refresh token, or by processing the OAuth app authorization flow again. I recommend reading the OAuth Guide and authorization documentation for more information.

 

Also, the "token/from_oauth1" route in particular you linked to is only meant for use with old OAuth 1 access tokens, retrieved from the old retired Dropbox API v1. If you do not have old OAuth 1 access tokens stored that you need to migrate, you should not use that route. If you are just developing your integration now, you would not have any OAuth 1 access tokens.

divyesh
Explorer | Level 4

Yes I followed the same oauth process and i found the token starting with sl.<token> but i'm getting this error using that token

 

Server error: `POST https://api.dropboxapi.com/2/files/search_v2` resulted in a `500 Internal Server Error` response: unexpected error occurred

Greg-DB
Dropbox Staff

A 500 error like that should indicate an issue on the Dropbox servers. If you're still seeing this issue, please share the code/steps to reproduce that, as well as several sample 'X-Dropbox-Request-Id' response header values. That should help us investigate. (Be sure to redact your access token though.) Thanks!

divyesh
Explorer | Level 4

Here is my code 

 

env('DROPBOX_TOKEN') is access token sl.<access token>

 

$this->client = new Client(env('DROPBOX_TOKEN'));
$this->adapter = new DropboxAdapter($this->client);
$checkFolderAvailable = $this->client->search('test');

in this search function i'm getting 500 error 

Greg-DB
Dropbox Staff

Thanks, can you share several sample 'X-Dropbox-Request-Id' response header values though?

Need more support?
Who's talking

Top contributors to this post

  • User avatar
    Greg-DB Dropbox Staff
  • User avatar
    divyesh Explorer | Level 4
What do Dropbox user levels mean?