@@ -34,6 +34,7 @@ def _start_device_authorization(
3434 response = client .post (
3535 "/login/device/authorization" , data = {"client_id" : settings .client_id }
3636 )
37+ logger .debug (f"Device authorization response status code: { response .status_code } " )
3738
3839 response .raise_for_status ()
3940
@@ -43,6 +44,7 @@ def _start_device_authorization(
4344def _fetch_access_token (client : httpx .Client , device_code : str , interval : int ) -> str :
4445 settings = Settings .get ()
4546
47+ logger .debug ("Starting to poll for access token" )
4648 while True :
4749 response = client .post (
4850 "/login/device/token" ,
@@ -52,22 +54,27 @@ def _fetch_access_token(client: httpx.Client, device_code: str, interval: int) -
5254 "grant_type" : "urn:ietf:params:oauth:grant-type:device_code" ,
5355 },
5456 )
57+ logger .debug (f"Token response status code: { response .status_code } " )
5558
5659 if response .status_code not in (200 , 400 ):
5760 response .raise_for_status ()
5861
5962 if response .status_code == 400 :
6063 data = response .json ()
64+ error = data .get ("error" )
65+ logger .debug (f"Token response error: { error } " )
6166
62- if data . get ( " error" ) != "authorization_pending" :
67+ if error != "authorization_pending" :
6368 response .raise_for_status ()
6469
6570 if response .status_code == 200 :
6671 break
6772
73+ logger .debug (f"Sleeping for { interval } seconds before retrying..." )
6874 time .sleep (interval )
6975
7076 response_data = TokenResponse .model_validate_json (response .text )
77+ logger .debug ("Access token received successfully." )
7178
7279 return response_data .access_token
7380
@@ -112,7 +119,8 @@ def login() -> Any:
112119 toolkit .print_line ()
113120
114121 with toolkit .progress ("Waiting for user to authorize..." ) as progress :
115- typer .launch (url )
122+ launch_cmd_res = typer .launch (url )
123+ logger .debug (f"Launch command result: { launch_cmd_res } " )
116124
117125 with client .handle_http_errors (progress ):
118126 access_token = _fetch_access_token (
0 commit comments