From 75f8415c55182a8d31961a9fa9e265b1ed080b43 Mon Sep 17 00:00:00 2001 From: Yurii Motov Date: Fri, 29 May 2026 09:40:10 +0200 Subject: [PATCH] =?UTF-8?q?=F0=9F=94=8A=20Add=20debug=20logging=20in=20`fa?= =?UTF-8?q?stapi=20login`=20command?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/fastapi_cloud_cli/commands/login.py | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/src/fastapi_cloud_cli/commands/login.py b/src/fastapi_cloud_cli/commands/login.py index af6d689..3dfa7cd 100644 --- a/src/fastapi_cloud_cli/commands/login.py +++ b/src/fastapi_cloud_cli/commands/login.py @@ -34,6 +34,7 @@ def _start_device_authorization( response = client.post( "/login/device/authorization", data={"client_id": settings.client_id} ) + logger.debug(f"Device authorization response status code: {response.status_code}") response.raise_for_status() @@ -43,6 +44,7 @@ def _start_device_authorization( def _fetch_access_token(client: httpx.Client, device_code: str, interval: int) -> str: settings = Settings.get() + logger.debug("Starting to poll for access token") while True: response = client.post( "/login/device/token", @@ -52,22 +54,27 @@ def _fetch_access_token(client: httpx.Client, device_code: str, interval: int) - "grant_type": "urn:ietf:params:oauth:grant-type:device_code", }, ) + logger.debug(f"Token response status code: {response.status_code}") if response.status_code not in (200, 400): response.raise_for_status() if response.status_code == 400: data = response.json() + error = data.get("error") + logger.debug(f"Token response error: {error}") - if data.get("error") != "authorization_pending": + if error != "authorization_pending": response.raise_for_status() if response.status_code == 200: break + logger.debug(f"Sleeping for {interval} seconds before retrying...") time.sleep(interval) response_data = TokenResponse.model_validate_json(response.text) + logger.debug("Access token received successfully.") return response_data.access_token @@ -112,7 +119,8 @@ def login() -> Any: toolkit.print_line() with toolkit.progress("Waiting for user to authorize...") as progress: - typer.launch(url) + launch_cmd_res = typer.launch(url) + logger.debug(f"Launch command result: {launch_cmd_res}") with client.handle_http_errors(progress): access_token = _fetch_access_token(