mirror of
https://github.com/Azgaar/Fantasy-Map-Generator.git
synced 2025-12-17 09:41:24 +01:00
change Fropbox clientId
This commit is contained in:
parent
6da81efeb2
commit
1290c0fea9
1 changed files with 19 additions and 16 deletions
35
dropbox.html
35
dropbox.html
|
|
@ -1,7 +1,7 @@
|
||||||
<!DOCTYPE html>
|
<!DOCTYPE html>
|
||||||
<html lang="en" dir="ltr">
|
<html lang="en" dir="ltr">
|
||||||
<head>
|
<head>
|
||||||
<meta charset="utf-8">
|
<meta charset="utf-8" />
|
||||||
<script type="text/javascript" src="https://unpkg.com/dropbox@10.8.0/dist/Dropbox-sdk.min.js"></script>
|
<script type="text/javascript" src="https://unpkg.com/dropbox@10.8.0/dist/Dropbox-sdk.min.js"></script>
|
||||||
<title>FMG Dropbox Auth</title>
|
<title>FMG Dropbox Auth</title>
|
||||||
</head>
|
</head>
|
||||||
|
|
@ -13,33 +13,36 @@
|
||||||
window.
|
window.
|
||||||
*/
|
*/
|
||||||
const REDIRECT_URI = window.location.origin + window.location.pathname;
|
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 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
|
else doAuth(); // start authentication
|
||||||
|
|
||||||
function doAuth() {
|
function doAuth() {
|
||||||
dbxAuth.getAuthenticationUrl(REDIRECT_URI, undefined, 'code', 'offline', undefined, undefined, true)
|
dbxAuth
|
||||||
.then(authUrl => {
|
.getAuthenticationUrl(REDIRECT_URI, undefined, "code", "offline", undefined, undefined, true)
|
||||||
|
.then(authUrl => {
|
||||||
window.sessionStorage.clear();
|
window.sessionStorage.clear();
|
||||||
window.sessionStorage.setItem("codeVerifier", dbxAuth.codeVerifier);
|
window.sessionStorage.setItem("codeVerifier", dbxAuth.codeVerifier);
|
||||||
window.location.href = authUrl;
|
window.location.href = authUrl;
|
||||||
})
|
})
|
||||||
.catch((error) => console.error(error));
|
.catch(error => console.error(error));
|
||||||
};
|
}
|
||||||
|
|
||||||
function getToken() {
|
function getToken() {
|
||||||
dbxAuth.setCodeVerifier(window.sessionStorage.getItem('codeVerifier'));
|
dbxAuth.setCodeVerifier(window.sessionStorage.getItem("codeVerifier"));
|
||||||
dbxAuth.getAccessTokenFromCode(REDIRECT_URI, searchParams.code)
|
dbxAuth
|
||||||
.then((resp) => {
|
.getAccessTokenFromCode(REDIRECT_URI, searchParams.code)
|
||||||
|
.then(resp => {
|
||||||
const token = resp.result.access_token;
|
const token = resp.result.access_token;
|
||||||
window.opener.Cloud.providers.dropbox.setDropBoxToken(token)
|
window.opener.Cloud.providers.dropbox.setDropBoxToken(token);
|
||||||
}).catch((error) => {
|
})
|
||||||
console.error(error)
|
.catch(error => {
|
||||||
});
|
console.error(error);
|
||||||
|
});
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
</body>
|
</body>
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue