diff --git a/pyiceberg/catalog/rest.py b/pyiceberg/catalog/rest.py index 996f921062..7f75ac2e9f 100644 --- a/pyiceberg/catalog/rest.py +++ b/pyiceberg/catalog/rest.py @@ -157,8 +157,10 @@ class RegisterTableRequest(IcebergBaseModel): class TokenResponse(IcebergBaseModel): access_token: str = Field() token_type: str = Field() - expires_in: int = Field() - issued_token_type: str = Field() + expires_in: Optional[int] = Field(default=None) + issued_token_type: Optional[str] = Field(default=None) + refresh_token: Optional[str] = Field(default=None) + scope: Optional[str] = Field(default=None) class ConfigResponse(IcebergBaseModel): diff --git a/tests/catalog/test_rest.py b/tests/catalog/test_rest.py index 4eb4680879..20fdbfa4ea 100644 --- a/tests/catalog/test_rest.py +++ b/tests/catalog/test_rest.py @@ -109,6 +109,24 @@ def test_token_200(rest_mock: Mocker) -> None: "token_type": "Bearer", "expires_in": 86400, "issued_token_type": "urn:ietf:params:oauth:token-type:access_token", + "scope": "openid offline", + "refresh_token": "refresh_token", + }, + status_code=200, + request_headers=OAUTH_TEST_HEADERS, + ) + assert ( + RestCatalog("rest", uri=TEST_URI, credential=TEST_CREDENTIALS)._session.headers["Authorization"] # pylint: disable=W0212 + == f"Bearer {TEST_TOKEN}" + ) + + +def test_token_200_without_optional_fields(rest_mock: Mocker) -> None: + rest_mock.post( + f"{TEST_URI}v1/oauth/tokens", + json={ + "access_token": TEST_TOKEN, + "token_type": "Bearer", }, status_code=200, request_headers=OAUTH_TEST_HEADERS,