Skip to content

Commit 570ba7c

Browse files
committed
address review feedback:prefer auth manager,move constant
1 parent 72be520 commit 570ba7c

File tree

5 files changed

+10
-10
lines changed

5 files changed

+10
-10
lines changed

pyiceberg/catalog/__init__.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,6 @@
7777
_ENV_CONFIG = Config()
7878

7979
TOKEN = "token"
80-
AUTH_MANAGER = "auth.manager"
8180
TYPE = "type"
8281
PY_CATALOG_IMPL = "py-catalog-impl"
8382
ICEBERG = "iceberg"

pyiceberg/catalog/rest/__init__.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,8 @@
2626
from tenacity import RetryCallState, retry, retry_if_exception_type, stop_after_attempt
2727

2828
from pyiceberg import __version__
29-
from pyiceberg.catalog import AUTH_MANAGER, BOTOCORE_SESSION, TOKEN, URI, WAREHOUSE_LOCATION, Catalog, PropertiesUpdateSummary
30-
from pyiceberg.catalog.rest.auth import AuthManager, AuthManagerAdapter, AuthManagerFactory, LegacyOAuth2AuthManager
29+
from pyiceberg.catalog import BOTOCORE_SESSION, TOKEN, URI, WAREHOUSE_LOCATION, Catalog, PropertiesUpdateSummary
30+
from pyiceberg.catalog.rest.auth import AUTH_MANAGER, AuthManager, AuthManagerAdapter, AuthManagerFactory, LegacyOAuth2AuthManager
3131
from pyiceberg.catalog.rest.response import _handle_non_200_response
3232
from pyiceberg.exceptions import (
3333
AuthorizationExpiredError,

pyiceberg/catalog/rest/auth.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,8 @@
3131
from pyiceberg.catalog.rest.response import TokenResponse, _handle_non_200_response
3232
from pyiceberg.exceptions import OAuthError
3333

34+
AUTH_MANAGER = "auth.manager"
35+
3436
COLON = ":"
3537
logger = logging.getLogger(__name__)
3638

pyiceberg/io/fsspec.py

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,8 @@
3636
from fsspec.implementations.local import LocalFileSystem
3737
from requests import HTTPError
3838

39-
from pyiceberg.catalog import AUTH_MANAGER, TOKEN, URI
39+
from pyiceberg.catalog import TOKEN, URI
40+
from pyiceberg.catalog.rest.auth import AUTH_MANAGER
4041
from pyiceberg.exceptions import SignError
4142
from pyiceberg.io import (
4243
ADLS_ACCOUNT_HOST,
@@ -124,12 +125,10 @@ def __call__(self, request: "AWSRequest", **_: Any) -> None:
124125
signer_headers: dict[str, str] = {}
125126

126127
auth_header: str | None = None
127-
if token := self.properties.get(TOKEN):
128+
if auth_manager := self.properties.get(AUTH_MANAGER):
129+
auth_header = auth_manager.auth_header()
130+
elif token := self.properties.get(TOKEN):
128131
auth_header = f"Bearer {token}"
129-
elif auth_manager := self.properties.get(AUTH_MANAGER):
130-
header = getattr(auth_manager, "auth_header", None)
131-
if callable(header):
132-
auth_header = header()
133132

134133
if auth_header:
135134
signer_headers["Authorization"] = auth_header

tests/io/test_fsspec.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@
2828
from fsspec.spec import AbstractFileSystem
2929
from requests_mock import Mocker
3030

31-
from pyiceberg.catalog import AUTH_MANAGER
31+
from pyiceberg.catalog.rest.auth import AUTH_MANAGER
3232
from pyiceberg.exceptions import SignError
3333
from pyiceberg.io import fsspec
3434
from pyiceberg.io.fsspec import FsspecFileIO, S3V4RestSigner

0 commit comments

Comments
 (0)