cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
Announcements
Want to learn some quick and useful tips to make your day easier? Check out how Calvin uses Replay to get feedback from other teams at Dropbox here.

Discuss Dropbox Developer & API

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

Refresh token using dropbox-sdk-js returns 400 error

Refresh token using dropbox-sdk-js returns 400 error

nort99
New member | Level 2

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#...) 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?

1 Reply 1

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.

Need more support?
Who's talking

Top contributors to this post

  • User avatar
    Greg-DB Dropbox Staff
What do Dropbox user levels mean?