From 4d55b8bfb0881159f4651bca716c2e0046d93c4e Mon Sep 17 00:00:00 2001 From: AI_Assistant Date: Sat, 22 Aug 2026 13:35:12 +0000 Subject: [PATCH] =?UTF-8?q?Drop=20FORGEJO=5FTOKEN=20requirement=20for=20up?= =?UTF-8?q?date=20checking=20=E2=80=94=20repo=20is=20public?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Forgejo's releases API and asset downloads both work unauthenticated for a public repo. check_latest_release() no longer raises if FORGEJO_TOKEN is blank; it only attaches the Authorization header when one is actually set (e.g. if this repo ever goes private again). --- android/main.py | 18 +++++++----------- 1 file changed, 7 insertions(+), 11 deletions(-) diff --git a/android/main.py b/android/main.py index 5ce50b0..06fe418 100644 --- a/android/main.py +++ b/android/main.py @@ -52,10 +52,11 @@ APP_VERSION = "0.1" # keep in sync with buildozer.spec's `version =` by hand # Forgejo repo this app checks for updates against (ported from # android-app-template — see that repo for the original writeup on each -# piece of this). Leave FORGEJO_TOKEN blank to disable update checking — -# the button still shows, but tells the user clearly that updates aren't -# configured rather than failing silently or crashing. Use a read-only -# token scoped to just this repo, never a general account token. +# piece of this). This repo is public, so FORGEJO_TOKEN is left blank — +# Forgejo's releases API and asset downloads both work unauthenticated +# for a public repo. Only set it if this repo ever goes private again; +# if so, use a read-only token scoped to just this repo, never a +# general account token. FORGEJO_BASE_URL = "https://repo.tas-tech.net" FORGEJO_OWNER = "tas-tech.net" FORGEJO_REPO = "event-tracker" @@ -154,14 +155,9 @@ def check_latest_release(): """ import certifi - if not FORGEJO_TOKEN: - raise RuntimeError( - "Update checking isn't configured — set FORGEJO_TOKEN at " - "the top of main.py." - ) - url = f"{FORGEJO_BASE_URL}/api/v1/repos/{FORGEJO_OWNER}/{FORGEJO_REPO}/releases/latest" - req = urllib.request.Request(url, headers={"Authorization": f"token {FORGEJO_TOKEN}"}) + headers = {"Authorization": f"token {FORGEJO_TOKEN}"} if FORGEJO_TOKEN else {} + req = urllib.request.Request(url, headers=headers) ctx = ssl.create_default_context(cafile=certifi.where()) with urllib.request.urlopen(req, context=ctx, timeout=15) as resp: data = json.load(resp)