44 lines
1.4 KiB
Python
44 lines
1.4 KiB
Python
import os
|
|
import requests
|
|
import traceback
|
|
|
|
# --- Configuration ---
|
|
GITEA_URL = "https://gitea.nathan-falvey.synology.me/nathan/"
|
|
USERNAME = "nathan"
|
|
GITEA_TOKEN = os.getenv("GITEA_TOKEN")
|
|
|
|
def debug_request():
|
|
headers = {"Authorization": f"token {GITEA_TOKEN}"}
|
|
|
|
print(f"--- Testing Connection to: {GITEA_URL} ---")
|
|
|
|
try:
|
|
# 1. Test Version API (Public-ish)
|
|
print("\n1. Testing Version API...")
|
|
v_res = requests.get(f"{GITEA_URL}/api/v1/version", headers=headers)
|
|
print(f"Status: {v_res.status_code}")
|
|
print(f"Response: {v_res.text}")
|
|
|
|
# 2. Test User Repo API (Requires Token)
|
|
print("\n2. Testing User Repos API...")
|
|
r_res = requests.get(f"{GITEA_URL}/api/v1/user/repos?type=owner", headers=headers)
|
|
print(f"Status: {r_res.status_code}")
|
|
|
|
if r_res.status_code != 200:
|
|
print("❌ ERROR: API rejected the token or URL is wrong.")
|
|
print(f"Server Message: {r_res.text}")
|
|
else:
|
|
repos = r_res.json()
|
|
print(f"✅ Success! Found {len(repos)} repositories.")
|
|
# Print just the first repo to see the structure
|
|
if repos:
|
|
print(f"Example Repo Data: {repos[0]['name']} - {repos[0]['html_url']}")
|
|
|
|
except Exception:
|
|
print("\n" + "!"*30)
|
|
print("STACK TRACE (Line Numbers):")
|
|
traceback.print_exc()
|
|
print("!"*30)
|
|
|
|
if __name__ == "__main__":
|
|
debug_request() |