mirror of
https://github.com/xiaoyaDev/xiaoya-alist.git
synced 2026-10-16 21:50:48 +08:00
fix: aliyun open token url invalid
This commit is contained in:
+4
-24
@@ -407,7 +407,7 @@ function check_aliyunpan_opentoken() {
|
||||
|
||||
}
|
||||
|
||||
local token code response refresh_token data_dir url_host
|
||||
local token response refresh_token data_dir
|
||||
data_dir="${1}"
|
||||
if [ -n "${2}" ]; then
|
||||
token="${2}"
|
||||
@@ -415,29 +415,17 @@ function check_aliyunpan_opentoken() {
|
||||
token=$(head -n1 "${data_dir}/myopentoken.txt")
|
||||
fi
|
||||
if cache_result "${data_dir}/myopentoken.txt" "${DDSREM_CONFIG_DIR}/cache_data/check_aliyunpan_opentoken.txt"; then
|
||||
if curl -Is https://api.xhofe.top/alist/ali_open/qr | head -n 1 | grep -q '200'; then
|
||||
url_host="api.xhofe.top"
|
||||
elif curl -Is https://api.nn.ci/alist/ali_open/qr | head -n 1 | grep -q '200'; then
|
||||
url_host="api.nn.ci"
|
||||
else
|
||||
url_host="api-cf.nn.ci"
|
||||
fi
|
||||
if ! response=$(curl -s "https://${url_host}/alist/ali_open/token" -X POST -H "User-Agent: $GLOBAL_UA" -H "Rererer: https://www.aliyundrive.com/" -H "Content-Type: application/json" -d '{"refresh_token":"'$token'", "grant_type": "refresh_token"}'); then
|
||||
if ! response=$(curl -s "http://auth.xiaoya.pro/api/ali_open/refresh" -X POST -H "User-Agent: $GLOBAL_UA" -H "Rererer: https://www.aliyundrive.com/" -H "Content-Type: application/json" -d '{"refresh_token":"'$token'", "grant_type": "refresh_token"}'); then
|
||||
WARN "网络问题,无法检测 阿里云盘 Open Token 有效性"
|
||||
cache_update "${data_dir}/myopentoken.txt" "${DDSREM_CONFIG_DIR}/cache_data/check_aliyunpan_opentoken.txt" "false"
|
||||
return 0
|
||||
fi
|
||||
code=$(echo "$response" | sed -n 's/.*"code":"\([^"]*\).*/\1/p')
|
||||
refresh_token=$(echo "$response" | sed 's/:\s*/:/g' | sed -n 's/.*"refresh_token":"\([^"]*\).*/\1/p')
|
||||
if [ -n "${refresh_token}" ]; then
|
||||
echo "${refresh_token}" > "${data_dir}/myopentoken.txt"
|
||||
INFO "有效 阿里云盘 Open Token"
|
||||
cache_update "${data_dir}/myopentoken.txt" "${DDSREM_CONFIG_DIR}/cache_data/check_aliyunpan_opentoken.txt" "true"
|
||||
return 0
|
||||
elif [ "${code}" == "Too Many Requests" ]; then
|
||||
WARN "已被限流,无法检测 阿里云盘 Open Token 有效性"
|
||||
cache_update "${data_dir}/myopentoken.txt" "${DDSREM_CONFIG_DIR}/cache_data/check_aliyunpan_opentoken.txt" "false"
|
||||
return 0
|
||||
else
|
||||
ERROR "无效 阿里云盘 Open Token"
|
||||
cache_update "${data_dir}/myopentoken.txt" "${DDSREM_CONFIG_DIR}/cache_data/check_aliyunpan_opentoken.txt" "false"
|
||||
@@ -509,16 +497,8 @@ function qrcode_mode_choose() {
|
||||
done
|
||||
extra_parameters="--qrcode_app=${qrcode_app}"
|
||||
elif [ "${2}" == "/aliyunopentoken/aliyunopentoken.py" ]; then
|
||||
if curl -Is https://api.xhofe.top/alist/ali_open/qr | head -n 1 | grep -q '200'; then
|
||||
extra_parameters="--api_url=api.xhofe.top"
|
||||
INFO "使用 api.xhofe.top 地址"
|
||||
elif curl -Is https://api.nn.ci/alist/ali_open/qr | head -n 1 | grep -q '200'; then
|
||||
extra_parameters="--api_url=api.nn.ci"
|
||||
INFO "使用 api.nn.ci 地址"
|
||||
else
|
||||
extra_parameters="--api_url=api-cf.nn.ci"
|
||||
INFO "使用 api-cf.nn.ci 地址"
|
||||
fi
|
||||
extra_parameters="--api_url=auth.xiaoya.pro"
|
||||
INFO "使用 auth.xiaoya.pro 地址"
|
||||
elif [ "${2}" == "/aliyuntoken/aliyuntoken.py" ]; then
|
||||
if curl -Is "https://passport.aliyundrive.com/newlogin/qrcode/generate.do" | head -n 1 | grep -q '200'; then
|
||||
extra_parameters="--api_url=base"
|
||||
|
||||
@@ -1,14 +1,12 @@
|
||||
# Aliyun Open Token
|
||||
|
||||
- api-cf.nn.ci
|
||||
- api.nn.ci
|
||||
- api.xhofe.top
|
||||
- auth.xiaoya.pro
|
||||
- aliyundrive-oauth.messense.me
|
||||
- openapi.aliyundrive.com
|
||||
|
||||
## Use
|
||||
|
||||
```shell
|
||||
Alist Open Token --> --api_url=api-cf.nn.ci/api.xhofe.top/api.nn.ci
|
||||
Xiaoya Open Token --> --api_url=auth.xiaoya.pro
|
||||
WebDav Open Token --> --api_url=aliyundrive-oauth.messense.me
|
||||
```
|
||||
@@ -21,42 +21,6 @@ if sys.platform.startswith("win32"):
|
||||
QRCODE_DIR = "qrcode.png"
|
||||
else:
|
||||
QRCODE_DIR = "/aliyunopentoken/qrcode.png"
|
||||
GLOBAL_UA = (
|
||||
"Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/127.0.0.0 Safari/537.36"
|
||||
)
|
||||
|
||||
headers = {
|
||||
"Accept": "*/*",
|
||||
"Accept-Encoding": "gzip, deflate, br, zstd",
|
||||
"Accept-Language": "zh-CN,zh;q=0.9",
|
||||
"Content-Type": "application/json",
|
||||
"Origin": "https://alist.nn.ci",
|
||||
"Referer": "https://alist.nn.ci/",
|
||||
"Sec-Ch-Ua": '"Not)A;Brand";v="99", "Google Chrome";v="127", "Chromium";v="127"',
|
||||
"Sec-Ch-Ua-Mobile": "?0",
|
||||
"Sec-Ch-Ua-Platform": '"Windows"',
|
||||
"Sec-Fetch-Dest": "empty",
|
||||
"Sec-Fetch-Mode": "cors",
|
||||
"Sec-Fetch-Site": "cross-site",
|
||||
"User-Agent": GLOBAL_UA,
|
||||
}
|
||||
headers_2 = {
|
||||
"Accept": "*/*",
|
||||
"Accept-Encoding": "gzip, deflate, br, zstd",
|
||||
"Accept-Language": "zh-CN,zh;q=0.9",
|
||||
"Content-Length": "111",
|
||||
"Content-Type": "application/json",
|
||||
"Origin": "https://alist.nn.ci",
|
||||
"Priority": "u=1, i",
|
||||
"Referer": "https://alist.nn.ci/",
|
||||
"Sec-CH-UA": '"Not)A;Brand";v="99", "Google Chrome";v="127", "Chromium";v="127"',
|
||||
"Sec-CH-UA-Mobile": "?0",
|
||||
"Sec-CH-UA-Platform": '"Windows"',
|
||||
"Sec-Fetch-Dest": "empty",
|
||||
"Sec-Fetch-Mode": "cors",
|
||||
"Sec-Fetch-Site": "cross-site",
|
||||
"User-Agent": GLOBAL_UA,
|
||||
}
|
||||
|
||||
|
||||
# pylint: disable=W0603
|
||||
@@ -71,18 +35,8 @@ def poll_qrcode_status(data, log_print, _api_url):
|
||||
if retry_times == 3:
|
||||
LAST_STATUS = 2
|
||||
break
|
||||
if _api_url == "api.xhofe.top":
|
||||
url = f"https://api.xhofe.top/proxy/https://open.aliyundrive.com/oauth/qrcode/{data}/status"
|
||||
_re = requests.get(url, headers=headers, timeout=10)
|
||||
elif _api_url == "api-cf.nn.ci":
|
||||
url = f"https://api-cf.nn.ci/proxy/https://open.aliyundrive.com/oauth/qrcode/{data}/status"
|
||||
_re = requests.get(url, timeout=10)
|
||||
elif _api_url == "api.nn.ci":
|
||||
url = f"https://api.nn.ci/proxy/https://open.aliyundrive.com/oauth/qrcode/{data}/status"
|
||||
_re = requests.get(url, timeout=10)
|
||||
else:
|
||||
url = f"https://openapi.aliyundrive.com/oauth/qrcode/{data}/status"
|
||||
_re = requests.get(url, timeout=10)
|
||||
url = f"https://openapi.aliyundrive.com/oauth/qrcode/{data}/status"
|
||||
_re = requests.get(url, timeout=10)
|
||||
if _re.status_code == 200:
|
||||
_re_data = json.loads(_re.text)
|
||||
if _re_data["status"] == "LoginSuccess":
|
||||
@@ -93,14 +47,8 @@ def poll_qrcode_status(data, log_print, _api_url):
|
||||
"client_id": "",
|
||||
"client_secret": "",
|
||||
}
|
||||
if _api_url == "api.xhofe.top":
|
||||
_re = requests.post(
|
||||
"https://api.xhofe.top/alist/ali_open/code", json=data_2, headers=headers_2, timeout=10
|
||||
)
|
||||
elif _api_url == "api-cf.nn.ci":
|
||||
_re = requests.post("https://api-cf.nn.ci/alist/ali_open/code", json=data_2, timeout=10)
|
||||
elif _api_url == "api.nn.ci":
|
||||
_re = requests.post("https://api.nn.ci/alist/ali_open/code", json=data_2, timeout=10)
|
||||
if _api_url == "auth.xiaoya.pro":
|
||||
_re = requests.post("http://auth.xiaoya.pro/api/ali_open/refresh", json=data_2, timeout=10)
|
||||
else:
|
||||
_re = requests.post(
|
||||
"https://aliyundrive-oauth.messense.me/oauth/access_token",
|
||||
@@ -122,10 +70,6 @@ def poll_qrcode_status(data, log_print, _api_url):
|
||||
logging.info("扫码成功, opentoken 已写入文件!")
|
||||
LAST_STATUS = 1
|
||||
break
|
||||
else:
|
||||
if json.loads(_re.text)["code"] == "Too Many Requests":
|
||||
logging.warning("Too Many Requests 请一小时后重试!")
|
||||
break
|
||||
else:
|
||||
if log_print:
|
||||
logging.info("等待用户扫码...")
|
||||
@@ -192,12 +136,8 @@ if __name__ == "__main__":
|
||||
if RE_COUNT == 3:
|
||||
logging.error("二维码生成失败,退出进程")
|
||||
os._exit(1)
|
||||
if args.api_url == "api.xhofe.top":
|
||||
re = requests.get("https://api.xhofe.top/alist/ali_open/qr", headers=headers, timeout=10)
|
||||
elif args.api_url == "api-cf.nn.ci":
|
||||
re = requests.get("https://api-cf.nn.ci/alist/ali_open/qr", timeout=10)
|
||||
elif args.api_url == "api.nn.ci":
|
||||
re = requests.get("https://api.nn.ci/alist/ali_open/qr", timeout=10)
|
||||
if args.api_url == "auth.xiaoya.pro":
|
||||
re = requests.get("http://auth.xiaoya.pro/api/ali_open/qr", timeout=10)
|
||||
else:
|
||||
re = requests.post(
|
||||
"https://aliyundrive-oauth.messense.me/oauth/authorize/qrcode",
|
||||
@@ -221,10 +161,6 @@ if __name__ == "__main__":
|
||||
if os.path.isfile(QRCODE_DIR):
|
||||
logging.info("二维码生成完成!")
|
||||
break
|
||||
else:
|
||||
if json.loads(re.text)["code"] == "Too Many Requests":
|
||||
logging.warning("Too Many Requests 请一小时后重试!")
|
||||
os._exit(0)
|
||||
time.sleep(1)
|
||||
RE_COUNT += 1
|
||||
except Exception as e: # pylint: disable=W0718
|
||||
|
||||
Reference in New Issue
Block a user