fix: stop sending accountId implicitly from the page client

The page client no longer resolves accountId from /v1/users/me. accountId is only sent when passed with --account-id, and a 403 for it now raises a clear error telling the user to omit it because the server scopes the listing to the caller's own account.
This commit is contained in:
2026-10-23 19:31:48 +03:00
parent 25569efc80
commit aaa0c99eb2
5 changed files with 27 additions and 21 deletions
+8 -6
View File
@@ -36,7 +36,10 @@ def parse_args() -> argparse.Namespace:
)
parser.add_argument(
"--account-id",
help="Sorgulanacak hesap ID'si (varsayılan: /v1/users/me içindeki account.id)",
help=(
"Sorgulanacak hesap ID'si; yalnızca en az POWER_USER yetkisiyle verilebilir (aksi halde "
"HTTP 403). Verilmezse sunucu kendi hesabınıza daraltır; normal kullanıcılar vermemelidir"
),
)
parser.add_argument(
"--recipient-id",
@@ -95,19 +98,18 @@ def main() -> int:
polygon = parse_polygon(args.polygon) if args.polygon else None
client = IklimClient.from_env(BASE_DIR / ".env")
service = PointAlarmService(client)
account_id = args.account_id or service.get_account_id()
store = PointStore(args.db)
summary = fetch_pages(
service,
store,
account_id=account_id,
account_id=args.account_id,
recipient_ids=args.recipient_id or None,
polygon=polygon,
page_size=args.page_size,
page_number=args.page_number,
)
records = store.records(summary.account_id, summary.registration_ids)
webhooks = store.webhooks(summary.account_id)
records = store.records(None, summary.registration_ids)
webhooks = store.webhooks_of(records)
if args.output:
path = timestamped_path(args.output)
write_records(path, records, webhooks)
@@ -125,7 +127,7 @@ def main() -> int:
if summary.duplicates:
logging.warning("Sayfalar arasında %s tekrar eden kayıt görüldü.", summary.duplicates)
if not args.output:
prompt_export(store, summary.account_id)
prompt_export(store, args.account_id)
except (ConfigurationError, ApiError, OSError) as exc:
logging.error("İşlem durduruldu: %s", exc)
return 1