After switching to API V2 authentication, now the step of launching the Dropbox Chooser is failing with this error.
Uncaught Error: Failed to open/load the window. Dropbox.choose and Dropbox.save should only be called from within a user-triggered event handler such as a tap or click event.
at E (https://www.dropbox.com/static/api/2/dropins.js:1:9789)
at x (https://www.dropbox.com/static/api/2/dropins.js:1:11599)
at Object.Dropbox.choose (https://www.dropbox.com/static/api/2/dropins.js:1:11672)
at HTMLImageElement.document.getElementById.onclick (https://client1.qa.mydomain.net/Scripts/Documents.js?v=4.5.0.18023:630:21)
at Object.trigger (https://ajax.aspnetcdn.com/ajax/jQuery/jquery-3.2.1.min.js:4:5679)
at HTMLImageElement.<anonymous> (https://ajax.aspnetcdn.com/ajax/jQuery/jquery-3.2.1.min.js:4:6138)
at Function.each (https://ajax.aspnetcdn.com/ajax/jQuery/jquery-3.2.1.min.js:2:2715)
at r.fn.init.each (https://ajax.aspnetcdn.com/ajax/jQuery/jquery-3.2.1.min.js:2:1003)
at r.fn.init.trigger (https://ajax.aspnetcdn.com/ajax/jQuery/jquery-3.2.1.min.js:4:6114)
at r.fn.init.r.fn.(anonymous function) [as click] (https://ajax.aspnetcdn.com/ajax/jQuery/jquery-3.2.1.min.js:4:6532)
I haven't modified the JS code, I do have this code embedded with my own App's client ID.
<script type="text/javascript" src="https://www.dropbox.com/static/api/2/dropins.js" id="dropboxjs" data-app-key="xxx"></script>
And this is the same code that worked for API V1 unchanged which triggered the chooser.
document.getElementById("DropBoxImg").onclick = function () {
Dropbox.choose({
linkType: "direct",
multiselect: DocumentModule.MultiSelectBool(),
success: function (files) {
DocumentModule.SetJsonFile(JSON.stringify({ files: files }));
DocumentModule.CloudUploadClick();
DocumentModule.DisplaySpinner(false);
},
cancel: function () {
},
extensions: ['.doc', '.docx', '.xls', '.txt', '.html', '.htm', '.tiff',
'.tif', '.jpg', '.jpeg', '.gif', '.pdf', '.xlsx']
});
};
And the above click event is triggered as follows
$('#DropBoxImg').click();
All I can think of the difference between the V1 and V2 change now is the way I'm authorizing the user.
Any help will be appreciated.
$('#DropBoxImg').click();being triggered by an actual user tap/click event? If you're calling it without a user event, the browser may block the window.