We’re Still Here to Help (Even Over the Holidays!) - find out more here.
Forum Discussion
Humza A.
11 years agoNew member | Level 1
Open Dropbox API Authorization request in a new Tab
I have a web application running on my local host and I am using Dropbox Core API in the web app to upload files. However, the Dropbox authentication page opens in the same tab in the browser as my w...
Humza A.
11 years agoNew member | Level 1
The code is the same as HelloWorld Dropbox code. I have pasted it below.
<!doctype html>
<html>
<head>
<script src="https://www.dropbox.com/static/api/dropbox-datastores-1.0-latest.js"></script>
<link rel="stylesheet" href="style.css">
</head>
<body>
<center>
<a id="writeButton" target="_BLANK" >Click to create hello.txt in Dropbox. </a>
</center>
<script>
var client = new Dropbox.Client({ key: '<your-app-key>' });
function doHelloWorld() {
client.writeFile('hello.txt', 'Hello, World!', function (error) {
if (error) {
alert('Error: ' + error);
} else {
alert('File written successfully!');
}
});
}
// Try to complete OAuth flow.
client.authenticate({ interactive: false }, function (error, client) {
if (error) {
alert('Error: ' + error);
}
});
if (client.isAuthenticated()) {
doHelloWorld();
}
document.getElementById('writeButton').onclick = function () {
client.authenticate(function (error, client) {
if (error) {
alert('Error: ' + error);
} else {
doHelloWorld();
}
});
}
</script>
</body>
</html>
About Dropbox API Support & Feedback
Find help with the Dropbox API from other developers.
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, Facebook or Instagram.
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!