@@ -887,7 +887,7 @@ def get_info(self) -> dict[str, Any]:
887887 dict[str, Any]: Information from server.
888888
889889 """
890- if self ._session is None :
890+ if self ._token_info . is_valid is None :
891891 return self ._get_server_info ()
892892
893893 response = self .get ("info" )
@@ -1464,7 +1464,8 @@ def _endpoint_to_url(
14641464 return f"{ base_url } /{ endpoint } "
14651465
14661466 def _logout (self ):
1467- logout_from_server (self ._base_url , self ._token_info .token )
1467+ if self ._token_info .is_valid :
1468+ logout_from_server (self ._base_url , self ._token_info .token )
14681469
14691470 def _get_server_info (self ) -> dict [str , Any ]:
14701471 """Get server info without a session."""
@@ -1477,18 +1478,17 @@ def _get_server_info(self) -> dict[str, Any]:
14771478 return response .json ()
14781479
14791480 def _get_user_info (self ) -> Optional [dict [str , Any ]]:
1480- if self ._token_info .token is None :
1481+ if (
1482+ self ._token_info .token is None
1483+ or self ._token_info .is_valid is False
1484+ ):
14811485 return None
14821486
14831487 if self ._token_info .is_service is None :
1488+ self .validate_token ()
14841489 if self ._token_info .is_valid is False :
14851490 return None
14861491
1487- self .validate_token ()
1488-
1489- if self ._token_info .is_valid is False :
1490- return None
1491-
14921492 response = self .get ("users/me" )
14931493 if response .status == 200 :
14941494 return response .data
0 commit comments