1616from enum import Enum
1717from typing import Any , Dict , List , Optional
1818
19- from google .auth import credentials as google_creds
2019from google .adk .auth .auth_credential import AuthCredential , AuthCredentialTypes
2120from google .adk .auth .auth_tool import AuthConfig , AuthScheme
21+ from google .auth import credentials as google_creds
2222
2323
2424class CredentialType (Enum ):
@@ -173,9 +173,9 @@ def from_adk_credentials(
173173 ):
174174 # Extract client_id, client_secret, and scopes from the credential object.
175175 return CredentialStrategy .user_identity (
176- client_id = auth_credential .oauth2 .client_id ,
177- client_secret = auth_credential .oauth2 .client_secret ,
178- scopes = auth_credential .oauth2 . scopes ,
176+ client_id = auth_credential .oauth2 .client_id or "" ,
177+ client_secret = auth_credential .oauth2 .client_secret or "" ,
178+ scopes = getattr ( auth_credential .oauth2 , " scopes" , []) ,
179179 )
180180
181181 # Handle HTTP Bearer
@@ -192,28 +192,28 @@ def from_adk_credentials(
192192 return CredentialStrategy .manual_token (
193193 token = auth_credential .http .credentials .token , scheme = "Bearer"
194194 )
195-
196- raise ValueError (
197- f"Unsupported HTTP authentication scheme: { scheme_type } "
198- )
195+
196+ raise ValueError (f"Unsupported HTTP authentication scheme: { scheme_type } " )
199197
200198 if (
201199 auth_credential .auth_type == AuthCredentialTypes .API_KEY
202200 and auth_credential .api_key
203201 ):
204202 if not auth_scheme :
205- raise ValueError ("API Key credentials require the auth_scheme definition." )
206-
203+ raise ValueError (
204+ "API Key credentials require the auth_scheme definition."
205+ )
206+
207207 header_name = getattr (auth_scheme , "name" , None )
208208 if not header_name :
209209 raise ValueError ("API Key scheme must define the header name." )
210-
210+
211211 location = getattr (auth_scheme , "in_" , "header" ) or "header"
212212 # Handle Enum (APIKeyIn.header) or string values
213213 location_str = str (location )
214214 if "." in location_str :
215215 location_str = location_str .split ("." )[- 1 ]
216-
216+
217217 if location_str .lower () != "header" :
218218 raise ValueError (
219219 f"Unsupported API Key location: { location } . Only 'header' is supported."
0 commit comments