From 1290c0fea951560a8c6b599723d090941b93b8ad Mon Sep 17 00:00:00 2001 From: Azgaar Date: Wed, 8 Sep 2021 09:51:36 +0300 Subject: [PATCH] change Fropbox clientId --- dropbox.html | 35 +++++++++++++++++++---------------- 1 file changed, 19 insertions(+), 16 deletions(-) diff --git a/dropbox.html b/dropbox.html index 64d578e7..bc7f1945 100644 --- a/dropbox.html +++ b/dropbox.html @@ -1,7 +1,7 @@ - + FMG Dropbox Auth @@ -13,33 +13,36 @@ window. */ const REDIRECT_URI = window.location.origin + window.location.pathname; - const dbxAuth = new Dropbox.DropboxAuth({ clientId: 'sp7tzwm27u2w5ns', }); + const dbxAuth = new Dropbox.DropboxAuth({clientId: "pdr9ae64ip0qno4"}); const spObj = new URLSearchParams(window.location.search); - const searchParams = Object.fromEntries(spObj.entries()) + const searchParams = Object.fromEntries(spObj.entries()); - if (searchParams.code) getToken() + if (searchParams.code) getToken(); else doAuth(); // start authentication function doAuth() { - dbxAuth.getAuthenticationUrl(REDIRECT_URI, undefined, 'code', 'offline', undefined, undefined, true) - .then(authUrl => { + dbxAuth + .getAuthenticationUrl(REDIRECT_URI, undefined, "code", "offline", undefined, undefined, true) + .then(authUrl => { window.sessionStorage.clear(); window.sessionStorage.setItem("codeVerifier", dbxAuth.codeVerifier); window.location.href = authUrl; - }) - .catch((error) => console.error(error)); - }; + }) + .catch(error => console.error(error)); + } function getToken() { - dbxAuth.setCodeVerifier(window.sessionStorage.getItem('codeVerifier')); - dbxAuth.getAccessTokenFromCode(REDIRECT_URI, searchParams.code) - .then((resp) => { + dbxAuth.setCodeVerifier(window.sessionStorage.getItem("codeVerifier")); + dbxAuth + .getAccessTokenFromCode(REDIRECT_URI, searchParams.code) + .then(resp => { const token = resp.result.access_token; - window.opener.Cloud.providers.dropbox.setDropBoxToken(token) - }).catch((error) => { - console.error(error) - }); + window.opener.Cloud.providers.dropbox.setDropBoxToken(token); + }) + .catch(error => { + console.error(error); + }); }