Dropbox API Support & Feedback
Find help with the Dropbox API from other developers.
I try to use the datastore API with javascript. This is my Code:
<!DOCTYPE html>
<html>
<head>
<meta content="text/html; charset=UTF-8" http-equiv="Content-Type">
<meta charset="UTF-8">
</head>
<body>
<script src="https://www.dropbox.com/static/api/dropbox-datastores-1.2-latest.js" type="text/javascript"></script>
<script>
var client = new Dropbox.Client({key: 'xxxxxxxxxxxx' });
// Try to finish OAuth authorization.
client.authenticate({interactive: false}, function (error) {
if (error) {
alert('Authentication error: ' + error);
}
});
alert(client.isAuthenticated());
if (client.isAuthenticated()) {
// Client is authenticated. Display UI.
}
</script>
</body>
</html>
The line alert(client.isAuthenticated()); always gives false which means that something went wrong with the authentication. Can someon tell me what I'm doing wrong?
The code I see here should all work once authentication has been started, but I don't see a call to start authentication.
Somewhere (e.g. on a button click) should be a call to client.authenticate(function (error) { ... });
(no { interactive: false }
). That will start the authentication flow, and then when the user returns to the page, your existing code should finish the auth process.
For an example, see https://www.dropbox.com/developers/datastore/tutorial/js#linking-accounts.
Why should I use a button to authenticate? I copied the code from the page that you have linked to and it should work fine. Do I have to do anything else to start authentication or does it suffice to call the method call client.authenticate?
You don't need to call client.authenticate
from a button handler (unless you're using a popup, which will get blocked unless invoked from a user action), but it's the typical way to build an app.
You don't need to do anything other than call client.authenticate
(without { interactive: false }
) to start the authentication process. I'd suggest following the tutorial exactly until you get working code.
Hi there!
If you need more help you can view your support options (expected response time for a 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!