@@ -113,7 +113,6 @@ def __init__(
113113 self ._client_id = _get_required_config_value (_CLIENT_ID_ENVVAR_NAME , client_id )
114114 self ._client_secret = _get_required_config_value (_CLIENT_SECRET_ENVVAR_NAME , client_secret )
115115
116-
117116 self ._metadata = (
118117 ("platform" , self ._platform ),
119118 ("python-version" , self ._python_version ),
@@ -289,7 +288,7 @@ def authenticate(self) -> str:
289288 "client_secret" : self ._client_secret ,
290289 }
291290 )
292- url = f" { self ._path } /auth/token" if self . _path and self . _path != "/" else "/auth/token"
291+ url = self ._get_auth_url ()
293292 conn .request ("POST" , url , data , headers )
294293 response = conn .getresponse ()
295294 if response .status != 200 :
@@ -302,6 +301,12 @@ def authenticate(self) -> str:
302301 _LOGGER .debug (f"Access token obtained for client { self ._client_id } " )
303302 return access_token
304303
304+ def _get_auth_url (self ) -> str :
305+ """Construct the authentication URL, handling trailing slashes in the path."""
306+ # Ensure the path does not have trailing slashes
307+ path = self ._path .rstrip ('/' ) if self ._path else ''
308+ return f"{ path } /auth/token"
309+
305310
306311class _ClientCallDetails (
307312 collections .namedtuple (
0 commit comments