mirror of
https://github.com/encounter/adk-python.git
synced 2026-07-09 18:19:28 -07:00
feat: Support refresh access token automatically for rest_api_tool
1. let auth_handler.py to utilize the oauth2 credential fetcher to exchange token 2. restructure tool_auth_handler.py to support refresh token PiperOrigin-RevId: 770901469
This commit is contained in:
committed by
Copybara-Service
parent
c5b063f1ff
commit
177980106b
@@ -449,7 +449,7 @@ class TestExchangeAuthToken:
|
||||
):
|
||||
"""Test when token exchange is not supported."""
|
||||
monkeypatch.setattr(
|
||||
"google.adk.auth.auth_handler.SUPPORT_TOKEN_EXCHANGE", False
|
||||
"google.adk.auth.oauth2_credential_fetcher.AUTHLIB_AVIALABLE", False
|
||||
)
|
||||
|
||||
handler = AuthHandler(auth_config_with_auth_code)
|
||||
@@ -537,7 +537,10 @@ class TestExchangeAuthToken:
|
||||
|
||||
assert result == oauth2_credentials_with_token
|
||||
|
||||
@patch("google.adk.auth.auth_handler.OAuth2Session", MockOAuth2Session)
|
||||
@patch(
|
||||
"google.adk.auth.oauth2_credential_fetcher.OAuth2Session",
|
||||
MockOAuth2Session,
|
||||
)
|
||||
def test_successful_token_exchange(self, auth_config_with_auth_code):
|
||||
"""Test a successful token exchange."""
|
||||
handler = AuthHandler(auth_config_with_auth_code)
|
||||
|
||||
Reference in New Issue
Block a user