feat(auth)!: expose access_token and refresh_token at top level of auth credentails

BREAKING CHANGE: `token` attribute of OAuth2Auth credentials used to be a dict containing both access_token and refresh_token, given that may cause confusions, now we replace it with access_token and refresh_token at top level of the auth credentials

PiperOrigin-RevId: 750346172
This commit is contained in:
Xiang (Sean) Zhou
2025-04-22 15:22:51 -07:00
committed by Copybara-Service
parent 49d8c0fbb2
commit 956fb912e8
6 changed files with 21 additions and 20 deletions

View File

@@ -126,12 +126,8 @@ def oauth2_credentials_with_token():
client_id="mock_client_id",
client_secret="mock_client_secret",
redirect_uri="https://example.com/callback",
token={
"access_token": "mock_access_token",
"token_type": "bearer",
"expires_in": 3600,
"refresh_token": "mock_refresh_token",
},
access_token="mock_access_token",
refresh_token="mock_refresh_token",
),
)
@@ -458,7 +454,7 @@ class TestParseAndStoreAuthResponse:
"""Test with an OAuth auth scheme."""
mock_exchange_token.return_value = AuthCredential(
auth_type=AuthCredentialTypes.OAUTH2,
oauth2=OAuth2Auth(token={"access_token": "exchanged_token"}),
oauth2=OAuth2Auth(access_token="exchanged_token"),
)
handler = AuthHandler(auth_config_with_exchanged)
@@ -573,6 +569,6 @@ class TestExchangeAuthToken:
handler = AuthHandler(auth_config_with_auth_code)
result = handler.exchange_auth_token()
assert result.oauth2.token["access_token"] == "mock_access_token"
assert result.oauth2.token["refresh_token"] == "mock_refresh_token"
assert result.oauth2.access_token == "mock_access_token"
assert result.oauth2.refresh_token == "mock_refresh_token"
assert result.auth_type == AuthCredentialTypes.OAUTH2