parent
6b222ac428
commit
dec75c4f82
@ -17,12 +17,12 @@
|
||||
<div class="mb-3">
|
||||
<label for="site-select" class="form-label">网盘名称</label>
|
||||
<select id="site-select" class="form-select">
|
||||
<!-- <option value="onedrive_pr" selected>OneDrive 个人账户</option>-->
|
||||
<option value="onedrive_go" selected>OneDrive 企业版本</option>
|
||||
<option value="onedrive_go" selected>OneDrive 企业账号</option>
|
||||
<option value="onedrive_pr">OneDrive 个人账号</option>
|
||||
<option value="onedrive_cn">OneDrive 世纪互联</option>
|
||||
<option value="onedrive_us">OneDrive 美国版本</option>
|
||||
<option value="onedrive_de">OneDrive 德国版本</option>
|
||||
<option value="alicloud_qr">阿里网盘 应用登录</option>
|
||||
<option value="alicloud_qr">阿里云盘 应用登录</option>
|
||||
<option value="alicloud_oa">阿里云盘 直接登录</option>
|
||||
<option value="baiduyun_go">百度网盘 验证登录</option>
|
||||
<option value="baiduyun_ob">百度网盘 OOB 验证</option>
|
||||
@ -54,7 +54,7 @@
|
||||
</div>
|
||||
|
||||
<div class="mb-3">
|
||||
<label for="callback-url" class="form-label">回调地址</label>
|
||||
<label for="callback-url" class="form-label">回调地址(Callback URL)</label>
|
||||
<input type="text" id="callback-url" class="form-control" value="https://api.oplist.org/onedrive/callback"
|
||||
readonly onclick="autoCopy(this)">
|
||||
</div>
|
||||
@ -68,12 +68,12 @@
|
||||
</div>
|
||||
|
||||
<div class="mb-3">
|
||||
<label for="access-token" class="form-label">访问秘钥</label>
|
||||
<label for="access-token" class="form-label">访问令牌(Access Token)</label>
|
||||
<textarea id="access-token" class="form-control" rows="3" readonly onclick="autoCopy(this)"></textarea>
|
||||
</div>
|
||||
|
||||
<div class="mb-3">
|
||||
<label for="refresh-token" class="form-label">刷新秘钥</label>
|
||||
<label for="refresh-token" class="form-label">刷新令牌(Refresh Token)</label>
|
||||
<textarea id="refresh-token" class="form-control" rows="3" readonly onclick="autoCopy(this)"></textarea>
|
||||
</div>
|
||||
<div class="mb-3" id="sharepoint-url-view">
|
||||
|
@ -29,137 +29,137 @@ async function getLogin(refresh = false) {
|
||||
});
|
||||
return;
|
||||
}
|
||||
// 阿里云盘扫码v2直接调用专用API,不需要构建传统的requests路径
|
||||
if (apps_type === "alicloud_oa" && !refresh) {
|
||||
await startAlicloud2Login();
|
||||
}
|
||||
// 阿里云盘扫码v2直接调用专用API,不需要构建传统的requests路径
|
||||
if (apps_type === "alicloud_oa" && !refresh) {
|
||||
await startAlicloud2Login();
|
||||
return;
|
||||
}
|
||||
// 刷新秘钥情况 =================================================
|
||||
let base_urls = "/requests?client_uid="
|
||||
if (refresh) {
|
||||
if (!refresh_ui) {
|
||||
Swal.fire({
|
||||
position: 'top',
|
||||
icon: 'info',
|
||||
title: '刷新失败',
|
||||
text: '请先填写Refresh Token',
|
||||
showConfirmButton: true,
|
||||
});
|
||||
return;
|
||||
}
|
||||
// 刷新秘钥情况 =================================================
|
||||
let base_urls = "/requests?client_uid="
|
||||
base_urls = "/renewapi?client_uid="
|
||||
}
|
||||
|
||||
|
||||
if (apps_type === "alicloud_oa") apps_subs = "alicloud2"
|
||||
let post_urls = "/" + apps_subs + base_urls + apps_uuid
|
||||
+ "&client_key=" + apps_keys + "&apps_types=" + apps_type
|
||||
+ "&server_use=" + server_use
|
||||
if (refresh) {
|
||||
post_urls += "&refresh_ui=" + refresh_ui
|
||||
}
|
||||
if (apps_subs === "baiduyun") post_urls += "&secret_key=" + secret_key
|
||||
try {
|
||||
const response = await fetch(post_urls, {
|
||||
method: 'GET', headers: {'Content-Type': 'application/json'}
|
||||
});
|
||||
// 解析响应内容 ===============================================
|
||||
const response_data = await response.json();
|
||||
// 刷新令牌模式 ===============================================
|
||||
if (refresh) {
|
||||
if (!refresh_ui) {
|
||||
if (response.status === 200) {
|
||||
access_key = document.getElementById("access-token")
|
||||
access_key.value = response_data.access_token;
|
||||
refresh_ui = document.getElementById("refresh-token")
|
||||
refresh_ui.value = response_data.refresh_token;
|
||||
Swal.fire({
|
||||
position: 'top',
|
||||
icon: 'info',
|
||||
title: '刷新失败',
|
||||
text: '请先填写Refresh Token',
|
||||
showConfirmButton: true,
|
||||
});
|
||||
return;
|
||||
}
|
||||
base_urls = "/renewapi?client_uid="
|
||||
}
|
||||
|
||||
|
||||
if (apps_type === "alicloud_oa") apps_subs = "alicloud2"
|
||||
let post_urls = "/" + apps_subs + base_urls + apps_uuid
|
||||
+ "&client_key=" + apps_keys + "&apps_types=" + apps_type
|
||||
+ "&server_use=" + server_use
|
||||
if (refresh) {
|
||||
post_urls += "&refresh_ui=" + refresh_ui
|
||||
}
|
||||
if (apps_subs === "baiduyun") post_urls += "&secret_key=" + secret_key
|
||||
try {
|
||||
const response = await fetch(post_urls, {
|
||||
method: 'GET', headers: {'Content-Type': 'application/json'}
|
||||
});
|
||||
// 解析响应内容 ===============================================
|
||||
const response_data = await response.json();
|
||||
// 刷新令牌模式 ===============================================
|
||||
if (refresh) {
|
||||
if (response.status === 200) {
|
||||
access_key = document.getElementById("access-token")
|
||||
access_key.value = response_data.access_token;
|
||||
refresh_ui = document.getElementById("refresh-token")
|
||||
refresh_ui.value = response_data.refresh_token;
|
||||
Swal.fire({
|
||||
icon: 'success',
|
||||
title: '刷新令牌成功:',
|
||||
showConfirmButton: true,
|
||||
timer: 1000
|
||||
});
|
||||
} else Swal.fire({
|
||||
icon: 'error',
|
||||
title: '刷新令牌失败: ',
|
||||
text: response_data.text,
|
||||
icon: 'success',
|
||||
title: '刷新令牌成功:',
|
||||
showConfirmButton: true,
|
||||
timer: 1000
|
||||
});
|
||||
return;
|
||||
}
|
||||
// 申请登录模式 ================================================================
|
||||
if (response.status === 200) {
|
||||
if (apps_subs === "onedrive" || apps_subs === "115cloud"
|
||||
|| apps_subs === "googleui" || apps_subs === "yandex"
|
||||
|| apps_type === "baiduyun_go"
|
||||
) {
|
||||
window.location.href = response_data.text;
|
||||
}
|
||||
// 百度云OOB模式(手动回调) ===============================================
|
||||
if (apps_type === "baiduyun_ob") {
|
||||
window.open(response_data.text);
|
||||
await Swal.fire({
|
||||
title: '提示',
|
||||
html: '请在新打开的页面获取授权码并粘贴到下方:' +
|
||||
'<input id="authCodeInput" type="text"' +
|
||||
'style="margin-top: 10px; width: calc(100% - 20px);">',
|
||||
confirmButtonText: 'OK',
|
||||
preConfirm: () => {
|
||||
return document.getElementById('authCodeInput').value;
|
||||
}
|
||||
}).then(async (result) => {
|
||||
if (result.isConfirmed) {
|
||||
const authCode = result.value;
|
||||
console.log('授权码:', authCode);
|
||||
window.location.href = "/baiduyun/callback" +
|
||||
"?server_oob=true" + "&secret_key=" + secret_key +
|
||||
"&client_key=" + apps_keys + "&code=" + authCode;
|
||||
}
|
||||
});
|
||||
}
|
||||
// 123网盘直接获取 ===========================================================
|
||||
if (apps_subs === "123cloud") {
|
||||
document.getElementById("access-token").value = response_data.text;
|
||||
return;
|
||||
}
|
||||
if (apps_type === "alicloud_qr") {
|
||||
let sid = response_data.sid;
|
||||
await Swal.fire({
|
||||
position: 'top',
|
||||
icon: 'info',
|
||||
title: '扫码登录',
|
||||
html: `<div>请扫码登录,完成后点确定</div>` +
|
||||
`<img src="${response_data.text}" alt="">`,
|
||||
showConfirmButton: true
|
||||
});
|
||||
post_urls = "/alicloud/callback" +
|
||||
"?client_id=" + apps_uuid +
|
||||
"&client_secret=" + apps_keys +
|
||||
"&grant_type=" + "authorization_code" +
|
||||
"&code=" + sid
|
||||
let auth_post = await fetch(post_urls, {method: 'GET'});
|
||||
let auth_data = await auth_post.json();
|
||||
if (auth_post.status === 200) {
|
||||
window.location.href = `/?access_token=${auth_data.access_token}`
|
||||
+ `&refresh_token=${auth_data.refresh_token}`
|
||||
+ `&client_uid=${apps_uuid}`
|
||||
+ `&client_key=${apps_keys}`;
|
||||
}
|
||||
}
|
||||
|
||||
} else Swal.fire({
|
||||
icon: 'error',
|
||||
title: "获取秘钥失败: " + response_data.text,
|
||||
showConfirmButton: true,
|
||||
timer: 1000
|
||||
});
|
||||
} catch (error) {
|
||||
Swal.fire({
|
||||
icon: 'error',
|
||||
title: '获取秘钥失败: ' + error,
|
||||
title: '刷新令牌失败: ',
|
||||
text: response_data.text,
|
||||
showConfirmButton: true,
|
||||
timer: 1000
|
||||
});
|
||||
return;
|
||||
}
|
||||
// 申请登录模式 ================================================================
|
||||
if (response.status === 200) {
|
||||
if (apps_subs === "onedrive" || apps_subs === "115cloud"
|
||||
|| apps_subs === "googleui" || apps_subs === "yandex"
|
||||
|| apps_type === "baiduyun_go"
|
||||
) {
|
||||
window.location.href = response_data.text;
|
||||
}
|
||||
// 百度云OOB模式(手动回调) ===============================================
|
||||
if (apps_type === "baiduyun_ob") {
|
||||
window.open(response_data.text);
|
||||
await Swal.fire({
|
||||
title: '提示',
|
||||
html: '请在新打开的页面获取授权码并粘贴到下方:' +
|
||||
'<input id="authCodeInput" type="text"' +
|
||||
'style="margin-top: 10px; width: calc(100% - 20px);">',
|
||||
confirmButtonText: 'OK',
|
||||
preConfirm: () => {
|
||||
return document.getElementById('authCodeInput').value;
|
||||
}
|
||||
}).then(async (result) => {
|
||||
if (result.isConfirmed) {
|
||||
const authCode = result.value;
|
||||
console.log('授权码:', authCode);
|
||||
window.location.href = "/baiduyun/callback" +
|
||||
"?server_oob=true" + "&secret_key=" + secret_key +
|
||||
"&client_key=" + apps_keys + "&code=" + authCode;
|
||||
}
|
||||
});
|
||||
}
|
||||
// 123网盘直接获取 ===========================================================
|
||||
if (apps_subs === "123cloud") {
|
||||
document.getElementById("access-token").value = response_data.text;
|
||||
return;
|
||||
}
|
||||
if (apps_type === "alicloud_qr") {
|
||||
let sid = response_data.sid;
|
||||
await Swal.fire({
|
||||
position: 'top',
|
||||
icon: 'info',
|
||||
title: '扫码登录',
|
||||
html: `<div>请扫码登录,完成后点确定</div>` +
|
||||
`<img src="${response_data.text}" alt="">`,
|
||||
showConfirmButton: true
|
||||
});
|
||||
post_urls = "/alicloud/callback" +
|
||||
"?client_id=" + apps_uuid +
|
||||
"&client_secret=" + apps_keys +
|
||||
"&grant_type=" + "authorization_code" +
|
||||
"&code=" + sid
|
||||
let auth_post = await fetch(post_urls, {method: 'GET'});
|
||||
let auth_data = await auth_post.json();
|
||||
if (auth_post.status === 200) {
|
||||
window.location.href = `/?access_token=${auth_data.access_token}`
|
||||
+ `&refresh_token=${auth_data.refresh_token}`
|
||||
+ `&client_uid=${apps_uuid}`
|
||||
+ `&client_key=${apps_keys}`;
|
||||
}
|
||||
}
|
||||
|
||||
} else Swal.fire({
|
||||
icon: 'error',
|
||||
title: "获取秘钥失败: " + response_data.text,
|
||||
showConfirmButton: true,
|
||||
timer: 1000
|
||||
});
|
||||
} catch (error) {
|
||||
Swal.fire({
|
||||
icon: 'error',
|
||||
title: '获取秘钥失败: ' + error,
|
||||
showConfirmButton: true,
|
||||
timer: 1000
|
||||
});
|
||||
}
|
||||
}
|
@ -90,6 +90,7 @@ async function getToken() {
|
||||
}
|
||||
if (siteSelect.value == "baiduyun_ob" ||
|
||||
siteSelect.value == "123cloud_go" ||
|
||||
// siteSelect.value == "onedrive_go" ||
|
||||
siteSelect.value == "onedrive_cn" ||
|
||||
siteSelect.value == "onedrive_us" ||
|
||||
siteSelect.value == "onedrive_de" ||
|
||||
|
@ -5,6 +5,10 @@ import * as configs from "./shares/configs";
|
||||
import * as refresh from "./shares/refresh";
|
||||
|
||||
const driver_map: Record<string, string[]> = {
|
||||
"onedrive_pr": [
|
||||
'https://login.microsoftonline.com/common/oauth2/v2.0/authorize',
|
||||
'https://login.microsoftonline.com/common/oauth2/v2.0/token'
|
||||
],
|
||||
"onedrive_go": [
|
||||
'https://login.microsoftonline.com/common/oauth2/v2.0/authorize',
|
||||
'https://login.microsoftonline.com/common/oauth2/v2.0/token'
|
||||
|
Loading…
x
Reference in New Issue
Block a user