I'm in the process of revamping a website that already exists, and although I have the code from the previous version, I'm encountering challenges replicating certain functionalities in the new iteration.
Here's the situation:
The user is presented with a web form where they can enter their Dropbox files for processing by the server.
Upon clicking a "Connect to Dropbox" button, the user goes through an authentication process, after which the web form receives "token" and "tokenSecret" values that are then included in the POST request sent to the server along with the file names.
I am unable to modify the server-side code, as it utilizes the token and token Secret values to fetch the files from Dropbox.
The code from the old version appears as follows:
function connectToDropbox(event)
{
var client;
event.preventDefault();
client = new Dropbox.Client(
{
key : "alku14nsuab=|izwocx+Xbnsa297hi/zcbhiwbvlmzvfsfheuzuawrt==",
sandbox : true
});
client.authDriver(new Dropbox.Drivers.Redirect(
{
useQuery : false,
rememberUser : true
}));
return client.authenticate(function(error, client)
{
$('.dropbox-linked').hide();
return $('.dropbox-unlinked').show();
});
}
The original developers didn't provide any details about the Dropbox app, so I created a new one.
However, when I run:
client = new Dropbox.Client({ key: "myappskey" });
I encounter the following error:
InvalidCharacterError: Failed to execute 'atob' on 'Window': The string to be decoded is not correctly encoded.
code: 5
message: "Failed to execute 'atob' on 'Window': The string to be decoded is not correctly encoded."
name: "InvalidCharacterError"
... (error stack details)
It is evident that something isn't right since my key resembles "spx9kiuauqx0hob."
Meanwhile, the original code uses: "alku14nsuab=|izwocx+Xbnsa297hi/zcbhiwbvlmzvfsfheuzuawrt=="
By examining the Dropbox source code, it seems to split at '|' and then call atob()
In my Dropbox app console, there is an app key and secret. It mentions that the key and secret are typically utilized by server apps, whereas JavaScript client apps should only use the key.
What should I input in the Dropbox.Client constructor to resolve this issue?
This pertains to Dropbox.js version 0.7.1
Thank you in advance