Skip to content

Commit bda59f2

Browse files
fix: FIT-1165: SDK using PATs cannot handle trailing slashes in base_url (#717)
1 parent 9c48495 commit bda59f2

1 file changed

Lines changed: 3 additions & 2 deletions

File tree

src/label_studio_sdk/tokens/client_ext.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import threading
2+
import urllib.parse
23
import typing
34
from datetime import datetime, timezone
45
import ssl
@@ -117,7 +118,7 @@ def refresh(self) -> TokenRefreshResponse:
117118
if isinstance(existing_client, httpx.Client):
118119
response = existing_client.request(
119120
method="POST",
120-
url=f"{self._base_url}/api/token/refresh/",
121+
url=urllib.parse.urljoin(f"{self._base_url}", "api/token/refresh/"),
121122
json={"refresh": self._api_key},
122123
headers={"Content-Type": "application/json"},
123124
)
@@ -128,7 +129,7 @@ def refresh(self) -> TokenRefreshResponse:
128129
with httpx.Client(**client_params) as sync_client:
129130
response = sync_client.request(
130131
method="POST",
131-
url=f"{self._base_url}/api/token/refresh/",
132+
url=urllib.parse.urljoin(f"{self._base_url}/", "api/token/refresh/"),
132133
json={"refresh": self._api_key},
133134
headers={"Content-Type": "application/json"},
134135
)

0 commit comments

Comments
 (0)