Hello
Please, do you have any idea how i can manage this ? Each 4 hours i get "expired_access_token" and user must re-log.
I just upgrade my old Dropbox SDK JS to the last version 10.8.0 + I did the changes to be compatible.
I have one Cordova app (iOS/Android/Win10).
The goal of my app is to : 1. User connect on dropbox (long life), user set "working hours" on my app, then each day/week user save/load data to/from Dropbox.
Here's my code:
Connexion code:
// 1. I init Dropbox connexion
dbx = new Dropbox.Dropbox({
clientId: dropboxClientId
});
// 2. I get auth url with redirect (custom url scheme)
var dropboxRedirectUri = 'MYAPP://dropbox_callback';
dbx.auth.getAuthenticationUrl(
dropboxRedirectUri,
'',
'code',
'offline',
[
'files.content.write',
'files.content.read',
],
'user',
true
)
.then((authUrl) => {
dropboxCodeVerifier = dbx.auth.codeVerifier;
cordova.InAppBrowser.open(authUrl, '_system');
});
// 3. User is redirect to his web browser to logoff, then user is redirected to my app
function handleOpenURL(url) {
// I read the "code" send by Dropbox
if (getUrlVars(url).code) {
dbx.auth.setCodeVerifier(dropboxCodeVerifier);
dbx.auth.getAccessTokenFromCode(dropboxRedirectUri, getUrlVars(url).code)
.then((response) => {
// I get the "access_token" (starts with sl as short-life)
localStorage['dropbox_access_token'] = response.result.access_token;
})
.then((response) => {
... User is now connected
})
.catch((error) => {
alert(error);
});
}
// At this point, i also get "refresh_token", but I'm sorry i don't know how to use it.
// So, after that, for each user action (save/load) i connect to dropbox + i launch my // actions with this code:
dbx = new Dropbox.Dropbox({
accessToken: localStorage['dropbox_access_token']
});
dbx.filesUpload({...
Best regards