recovered snapshot from suspended aaronjaworski710 (history unavailable)
This commit is contained in:
@@ -0,0 +1,62 @@
|
||||
#!/usr/bin/env python3
|
||||
"""starter_unlock.py — запросить starter-credit сессию (16 000 кредитов) для JWT.
|
||||
|
||||
Usage:
|
||||
python tools/starter_unlock.py <JWT> [return_to]
|
||||
python tools/starter_unlock.py --pool accounts.jsonl [email]
|
||||
|
||||
Печатает checkout URL (pay.viktor.com). Дальше: открыть URL, добавить карту
|
||||
(VCC, $0 verification-charge) → outcome станет "unlocked", кредиты зачислятся.
|
||||
Проверка после: GET /api/coworker/getting-started-status (credits_probe.py).
|
||||
"""
|
||||
import json, os, sys, urllib.request, urllib.error
|
||||
|
||||
API = "https://api.viktor.com"
|
||||
|
||||
def unlock(jwt, return_to="onboarding"):
|
||||
req = urllib.request.Request(API + "/api/coworker/starter-credit-unlock-session",
|
||||
method="POST", data=json.dumps({"return_to": return_to}).encode(),
|
||||
headers={"User-Agent": "Mozilla/5.0", "Authorization": "Bearer " + jwt,
|
||||
"Origin": "https://app.viktor.com", "Referer": "https://app.viktor.com/",
|
||||
"Content-Type": "application/json"})
|
||||
try:
|
||||
r = urllib.request.urlopen(req, timeout=30)
|
||||
return r.status, json.loads(r.read())
|
||||
except urllib.error.HTTPError as e:
|
||||
return e.code, e.read()[:300].decode(errors="replace")
|
||||
|
||||
def main():
|
||||
args = sys.argv[1:]
|
||||
if not args:
|
||||
print(__doc__); sys.exit(1)
|
||||
if args[0] == "--pool":
|
||||
pool = args[1] if len(args) > 1 else os.path.join(os.path.dirname(os.path.abspath(__file__)), "accounts.jsonl")
|
||||
want = args[2] if len(args) > 2 else None
|
||||
jwt = None
|
||||
with open(pool, encoding="utf-8") as f:
|
||||
for l in f:
|
||||
if not l.strip():
|
||||
continue
|
||||
a = json.loads(l)
|
||||
if want is None or a.get("email") == want:
|
||||
jwt = a.get("jwt")
|
||||
if jwt:
|
||||
print("using:", a.get("email"))
|
||||
break
|
||||
if not jwt:
|
||||
print("no jwt found in pool"); sys.exit(1)
|
||||
return_to = "onboarding"
|
||||
else:
|
||||
jwt = args[0]
|
||||
return_to = args[1] if len(args) > 1 else "onboarding"
|
||||
s, b = unlock(jwt, return_to)
|
||||
print("HTTP", s)
|
||||
print(json.dumps(b, ensure_ascii=False, indent=1) if isinstance(b, dict) else b)
|
||||
if isinstance(b, dict) and b.get("outcome") == "redirect":
|
||||
print("\nCHECKOUT URL (открыть в браузере, добавить VCC):")
|
||||
print(b["destination"])
|
||||
elif isinstance(b, dict) and b.get("outcome") == "unlocked":
|
||||
print("\nALREADY UNLOCKED, credits:", b.get("credits"))
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
Reference in New Issue
Block a user