@@ -94,14 +94,15 @@ def __init__(
9494 proxy_config = None ,
9595 ):
9696 self .url = url if url is not None else MerginClient .default_url ()
97- self ._auth_params = None
97+ self ._auth_params = {}
9898 self ._auth_session = None
9999 self ._user_info = None
100100 self ._server_type = None
101101 self ._server_version = None
102102 self .client_version = "Python-client/" + __version__
103103 if plugin_version is not None : # this could be e.g. "Plugin/2020.1 QGIS/3.14"
104104 self .client_version += " " + plugin_version
105+ self ._has_auth = auth_token is not None or login is not None or password is not None
105106 self .setup_logging ()
106107 if auth_token :
107108 try :
@@ -196,7 +197,10 @@ def _check_token(f):
196197 """Wrapper for creating/renewing authorization token."""
197198
198199 def wrapper (self , * args ):
199- if self ._auth_params :
200+
201+ # if user has not provided auth information (token or login/password) it does not make sense to try these checks
202+ # the client without auth can still be used to access public information like server config
203+ if self ._has_auth :
200204 if self ._auth_session :
201205 # Refresh auth token if it expired or will expire very soon
202206 delta = self ._auth_session ["expire" ] - datetime .now (timezone .utc )
@@ -209,7 +213,7 @@ def wrapper(self, *args):
209213 raise AuthTokenExpiredError ("Token has expired - please re-login" )
210214 else :
211215 # Create a new authorization token
212- self .log .info (f"No token - login user: { self ._auth_params [ 'login' ] } " )
216+ self .log .info (f"No token - login user: { self ._auth_params . get ( 'login' , None ) } " )
213217 if self ._auth_params .get ("login" , None ) and self ._auth_params .get ("password" , None ):
214218 self .login (self ._auth_params ["login" ], self ._auth_params ["password" ])
215219 else :
0 commit comments