Skip to content

Commit 6b281d0

Browse files
committed
Add automatic discovery of the auth service location
1 parent f1981ba commit 6b281d0

File tree

2 files changed

+5
-5
lines changed

2 files changed

+5
-5
lines changed

smartextract/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@
3737
from typing import Self # For Python ≤ 3.10
3838

3939

40-
__version__ = "0.6"
40+
__version__ = "0.6.1"
4141

4242
DEFAULT_BASE_URL = "https://api.smartextract.ai"
4343
DEFAULT_TIMEOUT = 600 # seconds

smartextract/_oauth.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -38,11 +38,11 @@ def __init__(self, base_url: str, token_file: str | Path | None) -> None:
3838

3939
@functools.cached_property
4040
def oauth_client(self) -> BaseOAuth2:
41+
with httpx.Client(base_url=self.base_url, follow_redirects=True) as client:
42+
r = client.get("/auth")
43+
r.raise_for_status()
4144
return OpenID(
42-
openid_configuration_endpoint=urljoin(
43-
self.base_url.replace("api.", "auth."),
44-
"auth/realms/smartextract/.well-known/openid-configuration",
45-
),
45+
openid_configuration_endpoint=f"{r.url}/.well-known/openid-configuration",
4646
client_id="smartextract-sdk",
4747
client_secret="",
4848
)

0 commit comments

Comments
 (0)