I have
I have a website that is trying to provide a service to a client so that it can download a file from Dropbox. For ease of development, I use Dropbox Selection . To do this, I authorize the domains that I expect to download and add the tag <script>suggested by Dropbox (with the appropriate one data-app-key) to my HTML page. Everything works sweetly.
Problem
Now I need to download the file selected by the user. Choosing Dropbox doesn't seem to provide any features for this; what it does is simply extract file information. In my case, this direct linkis to upload a file.
To download the file, I think I need to use Dropbox.Clientone that is defined in another Dropbox javascript library at //cdnjs.cloudflare.com/ajax/libs/dropbox.js/0.9.1/dropbox.min.js
So using this libarry, I run the code as follows:
var options = {
linkType: "direct",
success: function (files) {
var appKey = { key: 'APP KEY', secret: 'CLIENT SECRET', sandbox: true };
var client = new Dropbox.Client(appKey);
client.authenticate(function (error, client) {
if (error) {
console.log(error);
}
if (client.isAuthenticated()) {
for (var i = 0; i < files.length; i++) {
var file = files[i];
client.readFile(file.link, function (error, data) {
if (error) {
return console.log(error);
}
alert(data);
});
}
} else {
console.log("Error on authentication");
}
});
},
cancel: function () {
}
};
Dropbox.choose(options);
But all this does not allow me to report:

If I don’t call client.authenticate, I can’t upload the file as a “Not authorized error” error notification.
Question
How can I solve this problem.
source
share