You might see that the Dropbox Community team have been busy working on some major updates to the Community itself! So, here is some info on what’s changed, what’s staying the same and what you can expect from the Dropbox Community overall.

Forum Discussion

isaacfink's avatar
isaacfink
New member | Level 2
2 years ago

No auth function available for given request js sdk

I am using the js sdk like this

 

 

const client = new dropbox.Dropbox({
  accessToken: config.accessToken,
  clientId: config.appKey,
  clientSecret: config.secretKey,
});

dbx.auth.setRefreshToken(config.refreshToken);

await client.filesUpload({
  path: '/folder/image.jpg',
  contents: buffer,
});

 

But I am getting this error

'No auth function available for given request'
 

  • Greg-DB's avatar
    Greg-DB
    2 years ago

    This looks correct. I also just tried this all myself and it worked successfully for me. (Setting refreshToken on dropbox.Dropbox and also calling setRefreshToken is redundant, but it shouldn't cause this issue as long as you're using the correct value.)

     

    Please double check that you have copied in all of the values correctly, and didn't accidentally modify, misplace, or omit any of the values. For instance, your code here doesn't show how 'config' is set, so I can't replicate that exactly. I suggest printing out each each config value before you use them so you can check them.

     

    For instance, make sure:

    • 'config.appKey' is the same as the 'client_id' in the /oauth2/authorize URL that resulted in the authorization code
    • 'config.secretKey' is the app secret that corresponds to the app key in 'config.appKey'
    • 'config.appKey' is the same as the 'client_id' used in the /oauth2/token call
    • 'config.secretKey' is the same as the 'client_secret' used in the /oauth2/token call
    • 'config.refreshToken' is exactly the 'refresh_token' returned by /oauth2/token, and is a different string than each of the app key, app secret, access token, and authorization code
  • Greg-DB's avatar
    Greg-DB
    Icon for Dropbox Staff rankDropbox Staff

    In the code you shared here, you're not supplying the refresh token to the "client" object that you're attempting the upload with. You're supplying the refresh token to a different "dbx" object".

     

    Make sure you're giving the refresh token to the correct Dropbox object, e.g., your "client" variable.

     

    Also, note that the Dropbox object will need the following credentials in order to automatically perform the refresh, so make sure you're supplying all of these to the same object:

    • the refresh token
    • the app key used to retrieve that refresh token
    • only if the refresh token was not retrieved using PKCE: the app secret used to retrieve that refresh token
    • isaacfink's avatar
      isaacfink
      New member | Level 2
      The dbx was a typo, it's actually correct in my code but it still doesn't work
      • Greg-DB's avatar
        Greg-DB
        Icon for Dropbox Staff rankDropbox Staff

        In that case, please double check that you're supplying the correct credentials as outlined in my previous message, e.g., make sure you're using the correct app key/secret for that particular refresh token, etc.