Note that there are some explanatory texts on larger screens.

plurals
  1. PODownload file from Dropbox with JavaScript
    primarykey
    data
    text
    <h2>I have</h2> <p>I have a web site were try to provide a service to a client to be abel to download from Dropbox a file. For simplicity of development I use <a href="https://www.dropbox.com/developers/chooser" rel="nofollow noreferrer">Dropbox chooser</a>. For this I enable domains I expect to download from and include <code>&lt;script&gt;</code> tag suggested by Dropbox itself (with corresponding <code>data-app-key</code>) into my HTML page. Everything works sweet. </p> <h2>Problem</h2> <p>Now I need to download a file selected by the user. <a href="https://www.dropbox.com/developers/chooser" rel="nofollow noreferrer">Dropbox chooser</a> doesn't seem to provide any functionality for this, what it does, is just retrieve an information about file. In my case this is a <code>direct link</code>, to download the file.</p> <p>To download the file, seems to me, I need to use <code>Dropbox.Client</code> which is defined in another Dropbox javascript library at <a href="http://cdnjs.cloudflare.com/ajax/libs/dropbox.js/0.9.1/dropbox.min.js" rel="nofollow noreferrer">//cdnjs.cloudflare.com/ajax/libs/dropbox.js/0.9.1/dropbox.min.js</a></p> <p>So using that libarry I run the code like this: </p> <pre><code>//OPTIONS FOR DROPBOX CHOOSER var options = { linkType: "direct", // THIS FUNCITON RUNS WHEN USER SELECTS SOMETHING // FROM DOPBOX_CHOOSER success: function (files) { // DEFINE APP KET FOR DROPBOX_CLIENT (KEY, SECRET...), WHICH I GET // BY CREATING NEW "CORE API" TYPE:Full Dropbox APPLICATION ON // DROPBOX APP CONSOLE var appKey = { key: 'APP KEY', secret: 'CLIENT SECRET', sandbox: true }; //INIT CLIENT var client = new Dropbox.Client(appKey); //TRY TO AUTHENTICATE IT client.authenticate(function (error, client) { if (error) { console.log(error); } if (client.isAuthenticated()) { //READ FILES for (var i = 0; i &lt; files.length; i++) { var file = files[i]; client.readFile(file.link, function (error, data) { if (error) { return console.log(error); // Something went wrong. } alert(data); // data has the file's contents }); } } else { console.log("Error on authentication"); } }); }, cancel: function () { } }; //OPEN DROPBOX_CHOOSER Dropbox.choose(options); </code></pre> <p>But all this fails reporting me: </p> <p><img src="https://i.stack.imgur.com/RbA5Z.png" alt="enter image description here"></p> <p>If I <em>don't call</em> <code>client.authenticate</code> I'm not able to download file as get "Not Authorized error" notification. </p> <h2>Question</h2> <p>How can I resolve this issue. ?</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload