fix google drive cookie issue
add aliyun2 refresh add yandex refresh add baiduyun oob mode
This commit is contained in:
parent
0ffca42383
commit
be38793c51
@ -80,7 +80,7 @@ async function getToken() {
|
|||||||
if (siteSelect.value == "baiduyun_ob") {
|
if (siteSelect.value == "baiduyun_ob") {
|
||||||
document.getElementById("app-secret").value = "NqOMXF6XGhGRIGemsQ9nG0Na";
|
document.getElementById("app-secret").value = "NqOMXF6XGhGRIGemsQ9nG0Na";
|
||||||
document.getElementById("secret-key").value = "SVT6xpMdLcx6v4aCR4wT8BBOTbzFO8LM";
|
document.getElementById("secret-key").value = "SVT6xpMdLcx6v4aCR4wT8BBOTbzFO8LM";
|
||||||
|
document.getElementById("callback-url").value = "oob";
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
document.getElementById('client-id-view').hidden = false;
|
document.getElementById('client-id-view').hidden = false;
|
||||||
|
@ -20,7 +20,7 @@ export type Bindings = {
|
|||||||
baiduyun_uid: string, baiduyun_key: string,
|
baiduyun_uid: string, baiduyun_key: string,
|
||||||
cloud115_uid: string, cloud115_key: string,
|
cloud115_uid: string, cloud115_key: string,
|
||||||
googleui_uid: string, googleui_key: string,
|
googleui_uid: string, googleui_key: string,
|
||||||
YANDEX_CLIENT_ID: string, YANDEX_CLIENT_SECRET: string,
|
yandexui_uid: string, yandexui_key: string,
|
||||||
}
|
}
|
||||||
|
|
||||||
const app = new Hono<{ Bindings: Bindings }>()
|
const app = new Hono<{ Bindings: Bindings }>()
|
||||||
|
@ -1,6 +1,9 @@
|
|||||||
import {Context} from "hono";
|
import {Context} from "hono";
|
||||||
import {showErr} from "./error";
|
import {showErr} from "./error";
|
||||||
import * as local from "hono/cookie";
|
import * as local from "hono/cookie";
|
||||||
|
import * as refresh from "./shares/refresh"
|
||||||
|
import * as configs from "./shares/configs"
|
||||||
|
|
||||||
interface Token {
|
interface Token {
|
||||||
token_type?: string;
|
token_type?: string;
|
||||||
access_token?: string;
|
access_token?: string;
|
||||||
@ -13,14 +16,18 @@ interface Token {
|
|||||||
|
|
||||||
export async function yandexLogin(c: Context) {
|
export async function yandexLogin(c: Context) {
|
||||||
const env = c.env
|
const env = c.env
|
||||||
const client_uid: string = <string>c.req.query('client_uid');
|
let client_uid: string | undefined = c.req.query('client_uid');
|
||||||
const client_key: string = <string>c.req.query('client_key');
|
let client_key: string | undefined = c.req.query('client_key');
|
||||||
const server_use: string = <string>c.req.query('server_use');
|
let server_use: string | undefined = c.req.query('server_use');
|
||||||
if (server_use == "false" && (!client_uid || !client_key))
|
if(!server_use)
|
||||||
return c.json({text: "参数缺少"}, 500);
|
return c.json({text: "参数缺少"}, 500);
|
||||||
|
if (!client_uid || !client_key)
|
||||||
|
if (server_use == "false")
|
||||||
|
return c.json({text: "参数缺少"}, 500);
|
||||||
|
client_uid = client_key = ""
|
||||||
const params_all: Record<string, any> = {
|
const params_all: Record<string, any> = {
|
||||||
response_type: 'code',
|
response_type: 'code',
|
||||||
client_id: server_use == "true" ? env.YANDEX_CLIENT_ID : client_uid,
|
client_id: server_use == "true" ? env.yandexui_uid : client_uid,
|
||||||
};
|
};
|
||||||
if (server_use == "false") {
|
if (server_use == "false") {
|
||||||
local.setCookie(c, 'client_uid', client_uid);
|
local.setCookie(c, 'client_uid', client_uid);
|
||||||
@ -48,8 +55,8 @@ export async function yandexCallBack(c: Context) {
|
|||||||
const getToken = async (): Promise<Token> => {
|
const getToken = async (): Promise<Token> => {
|
||||||
const params = new URLSearchParams();
|
const params = new URLSearchParams();
|
||||||
params.append("grant_type", "authorization_code");
|
params.append("grant_type", "authorization_code");
|
||||||
params.append("client_id", env.YANDEX_CLIENT_ID);
|
params.append("client_id", env.yandexui_uid);
|
||||||
params.append("client_secret", env.YANDEX_CLIENT_SECRET);
|
params.append("client_secret", env.yandexui_key);
|
||||||
params.append("code", code);
|
params.append("code", code);
|
||||||
|
|
||||||
const resp = await fetch("https://oauth.yandex.com/token", {
|
const resp = await fetch("https://oauth.yandex.com/token", {
|
||||||
@ -102,5 +109,17 @@ export async function yandexCallBack(c: Context) {
|
|||||||
|
|
||||||
// 刷新令牌 ##############################################################################
|
// 刷新令牌 ##############################################################################
|
||||||
export async function genToken(c: Context) {
|
export async function genToken(c: Context) {
|
||||||
return c.json({text: "此网盘不支持"}, 500);
|
const clients_info: configs.Clients | undefined = configs.getInfo(c);
|
||||||
|
const refresh_text: string | undefined = c.req.query('refresh_ui');
|
||||||
|
if (!clients_info) return c.json({text: "传入参数缺少"}, 500);
|
||||||
|
if (!refresh_text) return c.json({text: "缺少刷新令牌"}, 500);
|
||||||
|
// 请求参数 ==========================================================================
|
||||||
|
const params: Record<string, any> = {
|
||||||
|
grant_type: "refresh_token",
|
||||||
|
refresh_token: refresh_text,
|
||||||
|
client_id: clients_info.servers ? c.env.alicloud_uid : clients_info.app_uid,
|
||||||
|
client_secret: clients_info.servers ? c.env.alicloud_key : clients_info.app_key,
|
||||||
|
};
|
||||||
|
return await refresh.genToken(c, "https://oauth.yandex.com/token", params, "POST",
|
||||||
|
"data.access_token", "data.refresh_token", "error");
|
||||||
}
|
}
|
@ -18,7 +18,9 @@
|
|||||||
"115cloud_uid": "",
|
"115cloud_uid": "",
|
||||||
"115cloud_key": "",
|
"115cloud_key": "",
|
||||||
"googleui_uid": "",
|
"googleui_uid": "",
|
||||||
"googleui_key": ""
|
"googleui_key": "",
|
||||||
|
"yandexui_uid": "",
|
||||||
|
"yandexui_key": ""
|
||||||
},
|
},
|
||||||
"site": {
|
"site": {
|
||||||
"bucket": "./public"
|
"bucket": "./public"
|
||||||
|
Loading…
x
Reference in New Issue
Block a user