cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
Announcements
What’s new: end-to-end encryption, Replay and Dash updates. Find out more about these updates, new features and more here.

Dropbox API Support & Feedback

Find help with the Dropbox API from other developers.

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

DropboxResponseError: Response failed with a 401 code

DropboxResponseError: Response failed with a 401 code

brtdvrs
Explorer | Level 4

hello,

I get an error 401 trying to connect to my dropbox, this is my code:

let dbx = new Dropbox.Dropbox({ accessToken: "REDACTED", clientId: "REDACTED", clientSecret: "REDACTED" });
 dbx.filesListFolder({ path: "" })
           .then(function (response) {
               if (response.result.entries > 1) {
                   return true
               } else {
                  return false
               }
})
.catch(function (error) {
             alert(error);
});

the same credentials works perfect on the server side in C#:

var dbx = new DropboxClient(DropBoxClass.Refresh_Token, DropBoxClass.Appkey, DropBoxClass.Appsecret);

 

 

1 Reply 1

Greg-DB
Dropbox Staff

In your JavaScript code, you're using the token as an access token, however in your .NET code, you're using the token as a refresh token. Access tokens and refresh tokens are different objects and are not interchangeable, so you can't use the same token both ways like that.

 

If the token you have is a refresh token, you should supply it to the JavaScript SDK Dropbox constructor using the "refreshToken" parameter (not "accessToken").

 

Also, I have now redacted them, but you posted your credentials here publicly. These credentials enable access to the connected account, and so as a matter of security should not be shared. That being the case, you may want to revoke them now since they're been exposed.

Need more support?
Who's talking

Top contributors to this post

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