One month down in 2025: How are your resolutions coming along? Check out how to get back on track here.
Forum Discussion
nort99
4 years agoNew member | Level 2
Refresh token using dropbox-sdk-js returns 400 error
Hi,
I'm using dropbox-sdk-js v10.5.0.
The use case is a single system with multiple users who submit files which we upload into a single Dropbox account. We used to use a long-lived token but now need to move across to the short lived tokens as they are being deprecated.
I have updated our system to include a one-off manual user flow to generate a refresh token (successfully), and store that refresh token on the server.
The JS client for subsequent users has access to that refresh token and it is passed into the Javascript library Dropbox constructor with no access token passed:
let dbx = new Dropbox({
clientId: data.dropbox.client_id,
//accessToken: ACCESS_TOKEN,
refreshToken: data.dropbox.refresh_token,
fetch: isoFetch,
});
I can see the logic in the library (https://github.com/dropbox/dropbox-sdk-js/blob/cc5136afe4df31284b29dde3933b4c7b72089086/src/auth.js#L348) results in a POST request to the oauth2/token endpoint with grant_type of 'refresh_token', however the call results in a JSON error response:
{"error_description": "No auth function available for given request", "error": "invalid_request"}
When I test the endpoint manually, I have to pass a client_id/client_secret Authorization header, and I must not pass client_id. This doesn't seem to be how the JS library functions.
Can you tell me how I should be using this library with a refresh token, so that it automatically creates a new access token on initialisation?
- Greg-DB
Dropbox Staff
[Cross-linking for reference: https://github.com/dropbox/dropbox-sdk-js/issues/769 ]
I've followed up on your GitHub post.
About Discuss Dropbox Developer & API
Make connections with other developers803 PostsLatest Activity: 5 hours ago
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!