We Want to Hear From You! What Do You Want to See on the Community? Tell us here!
Forum Discussion
divyesh
4 years agoExplorer | Level 4
Re: Oauth2 refresh token question - what happens when the refresh token expires?
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
- Greg-DB4 years ago
Dropbox Community Moderator
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.
- divyesh4 years agoExplorer | 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-DB4 years ago
Dropbox Community Moderator
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.
- divyesh4 years agoExplorer | 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-DB4 years ago
Dropbox Community Moderator
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!
- divyesh4 years agoExplorer | 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-DB4 years ago
Dropbox Community Moderator
Thanks, can you share several sample 'X-Dropbox-Request-Id' response header values though?
About Dropbox API Support & Feedback
Find help with the Dropbox API from other developers.6,036 PostsLatest Activity: 2 days ago
The Dropbox Community team is active from Monday to Friday. We try to respond to you as soon as we can, usually within 2 hours.
If you need more help you can view your support options (expected response time for an email or ticket is 24 hours), or contact us on X or Facebook.
For more info on available support options for your Dropbox plan, see this article.
If you found the answer to your question in this Community thread, please 'like' the post to say thanks and to let us know it was useful!