notion2api / verify_env.py
meyosaj406's picture
Create verify_env.py
3a58498 verified
# verify_env.py
import os, re, json
KEYS = [
"NOTION_COOKIE",
"NOTION_SPACE_ID",
"NOTION_USER_ID",
"NOTION_USER_EMAIL",
]
def redacted(v: str):
if v is None:
return None
s = v
return f"{s[:4]}{s[-4:]} (len={len(s)})"
def uuid_like(v: str):
return bool(re.fullmatch(r"[0-9a-fA-F-]{32,}", v or ""))
def has_quotes_or_newlines(v: str):
if not v:
return False
return any(ch in v for ch in ['\n', '\r', '"', "'"])
def main():
out = {}
for k in KEYS:
raw = os.getenv(k)
out[k] = {
"set": raw is not None,
"empty": (raw or "") == "",
"redacted": redacted(raw),
"uuid_like": uuid_like(raw) if k in ("NOTION_SPACE_ID","NOTION_USER_ID") else None,
"has_quotes_or_newlines": has_quotes_or_newlines(raw),
"starts_with_token_v2": raw.strip().startswith("token_v2=") if (raw and k=="NOTION_COOKIE") else None,
}
print(json.dumps(out, ensure_ascii=False, indent=2))
if __name__ == "__main__":
main()