Skip to content

Commit fe1556c

Browse files
committed
fix(skore-hub-project/login): Ignore token URI when using API key
1 parent 2f7bd86 commit fe1556c

File tree

1 file changed

+10
-5
lines changed
  • skore-hub-project/src/skore_hub_project/authentication

1 file changed

+10
-5
lines changed

skore-hub-project/src/skore_hub_project/authentication/uri.py

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,9 @@
55
from tempfile import gettempdir
66
from typing import Final
77

8-
DEFAULT: Final[str] = "https://api.skore.probabl.ai"
9-
ENVARNAME: Final[str] = "SKORE_HUB_URI"
8+
URI_DEFAULT: Final[str] = "https://api.skore.probabl.ai"
9+
URI_ENVARNAME: Final[str] = "SKORE_HUB_URI"
10+
API_KEY_ENVARNAME: Final[str] = "SKORE_HUB_API_KEY"
1011

1112

1213
class URIError(RuntimeError):
@@ -26,8 +27,12 @@ def persist(uri: str) -> None:
2627
def URI() -> str:
2728
"""URI used for ``skore hub`` authentication."""
2829
filepath = Filepath()
30+
uri_from_environment = environ.get(URI_ENVARNAME)
31+
32+
if environ.get(API_KEY_ENVARNAME):
33+
return uri_from_environment or URI_DEFAULT
34+
2935
uri_from_persistence = filepath.read_text() if filepath.exists() else None
30-
uri_from_environment = environ.get(ENVARNAME)
3136

3237
if (
3338
uri_from_persistence
@@ -37,8 +42,8 @@ def URI() -> str:
3742
raise URIError(
3843
f"\nBad condition: the persisted URI is conflicting with the environment:\n"
3944
f"\tFrom {filepath}: '{uri_from_persistence}'\n"
40-
f"\tFrom ${ENVARNAME}: '{uri_from_environment}'\n"
45+
f"\tFrom ${URI_ENVARNAME}: '{uri_from_environment}'\n"
4146
f"\nPlease run `skore-hub-logout`."
4247
)
4348

44-
return uri_from_persistence or uri_from_environment or DEFAULT
49+
return uri_from_persistence or uri_from_environment or URI_DEFAULT

0 commit comments

Comments
 (0)