mirror of
https://github.com/encounter/adk-python.git
synced 2026-07-09 18:19:28 -07:00
Merge pull request #1866 from hironow:hironow/type-fix-for-static
PiperOrigin-RevId: 782040553
This commit is contained in:
@@ -30,9 +30,9 @@ if TYPE_CHECKING:
|
||||
try:
|
||||
from authlib.integrations.requests_client import OAuth2Session
|
||||
|
||||
AUTHLIB_AVIALABLE = True
|
||||
AUTHLIB_AVAILABLE = True
|
||||
except ImportError:
|
||||
AUTHLIB_AVIALABLE = False
|
||||
AUTHLIB_AVAILABLE = False
|
||||
|
||||
|
||||
class AuthHandler:
|
||||
@@ -146,7 +146,7 @@ class AuthHandler:
|
||||
ValueError: If the authorization endpoint is not configured in the auth
|
||||
scheme.
|
||||
"""
|
||||
if not AUTHLIB_AVIALABLE:
|
||||
if not AUTHLIB_AVAILABLE:
|
||||
return (
|
||||
self.auth_config.raw_auth_credential.model_copy(deep=True)
|
||||
if self.auth_config.raw_auth_credential
|
||||
|
||||
@@ -33,9 +33,9 @@ from .base_credential_exchanger import CredentialExchangError
|
||||
try:
|
||||
from authlib.integrations.requests_client import OAuth2Session
|
||||
|
||||
AUTHLIB_AVIALABLE = True
|
||||
AUTHLIB_AVAILABLE = True
|
||||
except ImportError:
|
||||
AUTHLIB_AVIALABLE = False
|
||||
AUTHLIB_AVAILABLE = False
|
||||
|
||||
logger = logging.getLogger("google_adk." + __name__)
|
||||
|
||||
@@ -68,7 +68,7 @@ class OAuth2CredentialExchanger(BaseCredentialExchanger):
|
||||
"auth_scheme is required for OAuth2 credential exchange"
|
||||
)
|
||||
|
||||
if not AUTHLIB_AVIALABLE:
|
||||
if not AUTHLIB_AVAILABLE:
|
||||
# If authlib is not available, we cannot exchange the credential.
|
||||
# We return the original credential without exchange.
|
||||
# The client using this tool can decide to exchange the credential
|
||||
|
||||
@@ -29,9 +29,9 @@ try:
|
||||
from authlib.integrations.requests_client import OAuth2Session
|
||||
from authlib.oauth2.rfc6749 import OAuth2Token
|
||||
|
||||
AUTHLIB_AVIALABLE = True
|
||||
AUTHLIB_AVAILABLE = True
|
||||
except ImportError:
|
||||
AUTHLIB_AVIALABLE = False
|
||||
AUTHLIB_AVAILABLE = False
|
||||
|
||||
|
||||
logger = logging.getLogger("google_adk." + __name__)
|
||||
|
||||
@@ -34,9 +34,9 @@ from .base_credential_refresher import BaseCredentialRefresher
|
||||
try:
|
||||
from authlib.oauth2.rfc6749 import OAuth2Token
|
||||
|
||||
AUTHLIB_AVIALABLE = True
|
||||
AUTHLIB_AVAILABLE = True
|
||||
except ImportError:
|
||||
AUTHLIB_AVIALABLE = False
|
||||
AUTHLIB_AVAILABLE = False
|
||||
|
||||
logger = logging.getLogger("google_adk." + __name__)
|
||||
|
||||
@@ -63,7 +63,7 @@ class OAuth2CredentialRefresher(BaseCredentialRefresher):
|
||||
|
||||
# Handle regular OAuth2 credentials
|
||||
if auth_credential.oauth2:
|
||||
if not AUTHLIB_AVIALABLE:
|
||||
if not AUTHLIB_AVAILABLE:
|
||||
return False
|
||||
|
||||
return OAuth2Token({
|
||||
@@ -93,7 +93,7 @@ class OAuth2CredentialRefresher(BaseCredentialRefresher):
|
||||
|
||||
# Handle regular OAuth2 credentials
|
||||
if auth_credential.oauth2 and auth_scheme:
|
||||
if not AUTHLIB_AVIALABLE:
|
||||
if not AUTHLIB_AVAILABLE:
|
||||
return auth_credential
|
||||
|
||||
if not auth_credential.oauth2:
|
||||
|
||||
@@ -208,9 +208,9 @@ class TestOAuth2CredentialExchanger:
|
||||
|
||||
exchanger = OAuth2CredentialExchanger()
|
||||
|
||||
# Mock AUTHLIB_AVIALABLE to False
|
||||
# Mock AUTHLIB_AVAILABLE to False
|
||||
with patch(
|
||||
"google.adk.auth.exchanger.oauth2_credential_exchanger.AUTHLIB_AVIALABLE",
|
||||
"google.adk.auth.exchanger.oauth2_credential_exchanger.AUTHLIB_AVAILABLE",
|
||||
False,
|
||||
):
|
||||
result = await exchanger.exchange(credential, scheme)
|
||||
|
||||
@@ -456,7 +456,7 @@ class TestExchangeAuthToken:
|
||||
self, auth_config_with_auth_code, monkeypatch
|
||||
):
|
||||
"""Test when token exchange is not supported."""
|
||||
monkeypatch.setattr("google.adk.auth.auth_handler.AUTHLIB_AVIALABLE", False)
|
||||
monkeypatch.setattr("google.adk.auth.auth_handler.AUTHLIB_AVAILABLE", False)
|
||||
|
||||
handler = AuthHandler(auth_config_with_auth_code)
|
||||
result = await handler.exchange_auth_token()
|
||||
|
||||
Reference in New Issue
Block a user