@@ -420,18 +420,19 @@ def _get_device_code_response(self, device_auth_endpoint: str, data: dict[str, A
420420 "Content-Type" : "application/x-www-form-urlencoded;charset=UTF-8" ,
421421 },
422422 )
423- # Try to parse JSON response - handle different response types
424- try :
425- return device_flow_response .json ()
426- except (AttributeError , TypeError ):
427- # Fallback: try to get text content, which is the case for example if getting MSAL's NormalizedResponse
428- try :
429- return json .loads (device_flow_response .text )
430- except (JSONDecodeError , TypeError , AttributeError ) as e :
431- raise CogniteAuthError ("Unable to parse device flow response" ) from e
432423 except (requests .exceptions .RequestException , ValueError ) as e :
433424 raise CogniteAuthError ("Error initiating device flow" ) from e
434425
426+ # Try to parse JSON response - handle different response types
427+ try :
428+ return device_flow_response .json ()
429+ except (json .JSONDecodeError , TypeError , AttributeError ):
430+ # Fallback: try to get text content, which is the case for example if getting MSAL's NormalizedResponse
431+ try :
432+ return json .loads (device_flow_response .text )
433+ except (json .JSONDecodeError , TypeError , AttributeError ) as e :
434+ raise CogniteAuthError ("Unable to parse device flow response" ) from e
435+
435436 def _get_token (self , convert_timestamps : bool = True ) -> dict [str , Any ]:
436437 """Return a dictionary with the current token and expiry time."""
437438 if self ._token_cache_path .exists ():
0 commit comments