diff --git a/pyiceberg/catalog/rest.py b/pyiceberg/catalog/rest.py index 3132af9fcd..e0e88ec450 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 21b4d95556..c4668a71ec 100644 --- a/tests/catalog/test_rest.py +++ b/tests/catalog/test_rest.py @@ -108,6 +108,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,