Files
exposedgays/deploy/cf-probe-old-token.py

40 lines
1.1 KiB
Python

#!/usr/bin/env python3
import json
import urllib.error
import urllib.request
CF = "https://api.cloudflare.com/client/v4"
ACCOUNT = "2599c23bbb1255dbb73e8d34b4115fda"
DOMAIN = "exposedgays.com"
TOK = "cfut_vF51avCWJV9EnCM4lXS2v60jXo6TPQZ0yxESHuRn5b0f3515"
def call(path, method="GET", body=None):
req = urllib.request.Request(
CF + path,
data=json.dumps(body).encode() if body else None,
method=method,
headers={"Authorization": f"Bearer {TOK}", "Content-Type": "application/json"},
)
try:
with urllib.request.urlopen(req, timeout=45) as r:
return json.load(r)
except urllib.error.HTTPError as e:
return json.loads(e.read().decode())
for path in [
"/user/tokens/verify",
f"/zones?name={DOMAIN}",
"/zones?per_page=50",
f"/accounts/{ACCOUNT}/tokens/verify",
]:
res = call(path)
print(path, "->", json.dumps(res)[:500])
create = call(
"/zones",
"POST",
{"name": DOMAIN, "account": {"id": ACCOUNT}, "type": "full", "jump_start": False},
)
print("create ->", json.dumps(create))