Cut the Clutter: Test Ignore Files Feature - sign up to become a beta tester here.

Forum Discussion

brtdvrs's avatar
brtdvrs
Helpful | Level 5
3 years ago

DropboxResponseError: Response failed with a 401 code

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

  • Greg-DB's avatar
    Greg-DB
    Icon for Dropbox Community Moderator rankDropbox Community Moderator
    3 years ago

    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.

About Dropbox API Support & Feedback

Node avatar for Dropbox API Support & Feedback
Find help with the Dropbox API from other developers.6,038 PostsLatest Activity: 6 years ago
415 Following

The Dropbox Community team is active from Monday to Friday. We try to respond to you as soon as we can, usually within 2 hours.

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!