cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
Announcements
Share your feedback on the Document Scanning Experience in the Dropbox App right here.

Discuss Dropbox Developer & API

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

No auth function available for given request js sdk

No auth function available for given request js sdk

isaacfink
New member | Level 2
Go to solution

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'
 

1 Accepted Solution

Accepted Solutions

Greg-DB
Dropbox Staff
Go to solution

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

View solution in original post

9 Replies 9

Greg-DB
Dropbox Staff
Go to solution

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
New member | Level 2
Go to solution
The dbx was a typo, it's actually correct in my code but it still doesn't work

Greg-DB
Dropbox Staff
Go to solution

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.

isaacfink
New member | Level 2
Go to solution

I tried all of the above, I made sure the tokens and secrets are all correct but still nothing

Greg-DB
Dropbox Staff
Go to solution

I'll be happy to look into this further, but I'll need some more information. Please reply with:

  • the version number of the JavaScript SDK you're using
  • the steps to reproduce the issue, including the actual code, but don't include any access token, refresh token, or app key/secret themselves
  • the full text of the unexpected output/error

isaacfink
New member | Level 2
Go to solution

Thanks, here is the information you asked for

dropbox@10.34.0

 

here is what I did, I created an app and went to this url

https://www.dropbox.com/oauth2/authorize?client_id=<CLIENT_ID>&response_type=code&token_access_type=...

I got redirected to this screen

SCR-20230907-puv.png

I then entered this in my terminal

curl https://api.dropbox.com/oauth2/token \
    -d code=<the code I got from the previous image> \
    -d grant_type=authorization_code \
    -d client_id=<APP KEY> \
    -d client_secret=<APP SECRET>

 

and got a response object

In my js script I have the following code

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

client.auth.setRefreshToken(config.refreshToken);

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

the access token and refresh token are what I got from the response from the curl request

I tried removing the refresh token in the class init and removing the client.auth.setRefreshToken but whatever combination of those I try gives me that error, I tried removing the accessToken an/or the clientId but nothing helped

 

isaacfink
New member | Level 2
Go to solution

The full text of the error is this

{
  name: "DropboxResponseError",
  status: 400,
  headers: {
  },
  error: {
    error: "invalid_request",
    error_description: "No auth function available for given request",
  },
}

Greg-DB
Dropbox Staff
Go to solution

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

isaacfink
New member | Level 2
Go to solution

Turns out the secret key was undefined, so much for avoiding typescript, thanks

Need more support?
Who's talking

Top contributors to this post

  • User avatar
    isaacfink New member | Level 2
  • User avatar
    Greg-DB Dropbox Staff
What do Dropbox user levels mean?