54 lines
2.2 KiB
Python
54 lines
2.2 KiB
Python
# -*- coding: utf-8 -*-
|
|
"""Read-only: why assign cards show OAuth异常 on dylive."""
|
|
import json
|
|
import paramiko
|
|
|
|
REMOTE = r'''#!/bin/bash
|
|
CS=$(mktemp)
|
|
curl -sS -m 20 -c "$CS" -b "$CS" -X POST http://127.0.0.1:8014/api/auth/login \
|
|
-H 'Content-Type: application/json' \
|
|
-d '{"username":"hackrobot","password":"Xiao4669805@"}' >/dev/null
|
|
curl -sS -m 60 -b "$CS" http://127.0.0.1:8014/api/youtube/assign/groups > /tmp/groups.json
|
|
python3 - <<'PY'
|
|
import json
|
|
rows=json.load(open("/tmp/groups.json"))
|
|
groups=rows if isinstance(rows,list) else rows.get("groups") or []
|
|
print("group_count", len(groups))
|
|
keys=("name","oauth_ok","oauth_status","oauth_error","oauth_message","token_ok","has_refresh_token",
|
|
"channel_pk","youtube_oauth","oauth","client","profile","auth_error","token_error")
|
|
# print first group keys related to oauth
|
|
if groups:
|
|
g0=groups[0]
|
|
oauth_keys=sorted(k for k in g0.keys() if "oauth" in k.lower() or "token" in k.lower() or "auth" in k.lower() or "ypp" in k.lower())
|
|
print("oauth_related_keys", oauth_keys)
|
|
for g in groups:
|
|
name=str(g.get("name") or "")
|
|
interesting=any(x in name.lower() for x in ("nomadvlog","nice street","china street","nomadesim","asian","nomadro"))
|
|
# also dump any with oauth fail flags
|
|
flags=[]
|
|
for k,v in g.items():
|
|
lk=k.lower()
|
|
if "oauth" in lk or "token" in lk:
|
|
if v not in (None,"",0,False,[],{}):
|
|
flags.append(f"{k}={v!r}"[:120])
|
|
if interesting or any("异常" in str(v) or v is False for k,v in g.items() if "oauth" in k.lower()):
|
|
print("---", name)
|
|
print(" id", g.get("id"))
|
|
print(" channel_pk", g.get("channel_pk"), "yt", g.get("youtube_channel_id"))
|
|
print(" enabled", g.get("enabled"), "category", g.get("category"))
|
|
for line in flags[:20]:
|
|
print(" ", line)
|
|
PY
|
|
'''
|
|
|
|
c = paramiko.SSHClient()
|
|
c.set_missing_host_key_policy(paramiko.AutoAddPolicy())
|
|
c.connect("107.173.30.245", 22, "root", "Xiao4669805", timeout=30, allow_agent=False, look_for_keys=False)
|
|
sftp = c.open_sftp()
|
|
with sftp.file("/tmp/_probe_oauth.sh", "w") as f:
|
|
f.write(REMOTE)
|
|
sftp.close()
|
|
_, o, e = c.exec_command("bash /tmp/_probe_oauth.sh", timeout=90)
|
|
print((o.read() + e.read()).decode("utf-8", "replace"))
|
|
c.close()
|