1919from typing import Dict
2020from typing import List
2121from typing import Literal
22- from typing import Optional
2322
2423from pydantic import alias_generators
2524from pydantic import BaseModel
@@ -40,9 +39,9 @@ class BaseModelWithConfig(BaseModel):
4039class HttpCredentials (BaseModelWithConfig ):
4140 """Represents the secret token value for HTTP authentication, like user name, password, oauth token, etc."""
4241
43- username : Optional [ str ] = None
44- password : Optional [ str ] = None
45- token : Optional [ str ] = None
42+ username : str | None = None
43+ password : str | None = None
44+ token : str | None = None
4645
4746 @classmethod
4847 def model_validate (cls , data : Dict [str , Any ]) -> "HttpCredentials" :
@@ -62,40 +61,43 @@ class HttpAuth(BaseModelWithConfig):
6261 # Examples: 'basic', 'bearer'
6362 scheme : str
6463 credentials : HttpCredentials
65- additional_headers : Optional [ Dict [str , str ]] = None
64+ additional_headers : Dict [str , str ] | None = None
6665
6766
6867class OAuth2Auth (BaseModelWithConfig ):
6968 """Represents credential value and its metadata for a OAuth2 credential."""
7069
71- client_id : Optional [ str ] = None
72- client_secret : Optional [ str ] = None
70+ client_id : str | None = None
71+ client_secret : str | None = None
7372 # tool or adk can generate the auth_uri with the state info thus client
7473 # can verify the state
75- auth_uri : Optional [ str ] = None
74+ auth_uri : str | None = None
7675 # A unique value generated at the start of the OAuth flow to bind the user's
7776 # session to the authorization request. This value is typically stored with
7877 # user session and passed to backend for validation.
79- nonce : Optional [ str ] = None
80- state : Optional [ str ] = None
78+ nonce : str | None = None
79+ state : str | None = None
8180 # tool or adk can decide the redirect_uri if they don't want client to decide
82- redirect_uri : Optional [str ] = None
83- auth_response_uri : Optional [str ] = None
84- auth_code : Optional [str ] = None
85- access_token : Optional [str ] = None
86- refresh_token : Optional [str ] = None
87- id_token : Optional [str ] = None
88- expires_at : Optional [int ] = None
89- expires_in : Optional [int ] = None
90- audience : Optional [str ] = None
91- token_endpoint_auth_method : Optional [
81+ redirect_uri : str | None = None
82+ auth_response_uri : str | None = None
83+ auth_code : str | None = None
84+ access_token : str | None = None
85+ refresh_token : str | None = None
86+ id_token : str | None = None
87+ expires_at : int | None = None
88+ expires_in : int | None = None
89+ audience : str | None = None
90+ code_verifier : str | None = None
91+ code_challenge_method : str | None = None
92+ token_endpoint_auth_method : (
9293 Literal [
9394 "client_secret_basic" ,
9495 "client_secret_post" ,
9596 "client_secret_jwt" ,
9697 "private_key_jwt" ,
9798 ]
98- ] = "client_secret_basic"
99+ | None
100+ ) = "client_secret_basic"
99101
100102
101103class ServiceAccountCredential (BaseModelWithConfig ):
@@ -166,11 +168,11 @@ class ServiceAccount(BaseModelWithConfig):
166168 when ``use_id_token`` is True.
167169 """
168170
169- service_account_credential : Optional [ ServiceAccountCredential ] = None
170- scopes : Optional [ List [str ]] = None
171- use_default_credential : Optional [ bool ] = False
172- use_id_token : Optional [ bool ] = False
173- audience : Optional [ str ] = None
171+ service_account_credential : ServiceAccountCredential | None = None
172+ scopes : List [str ] | None = None
173+ use_default_credential : bool | None = False
174+ use_id_token : bool | None = False
175+ audience : str | None = None
174176
175177 @model_validator (mode = "after" )
176178 def _validate_config (self ) -> ServiceAccount :
@@ -275,9 +277,9 @@ class AuthCredential(BaseModelWithConfig):
275277 auth_type : AuthCredentialTypes
276278 # Resource reference for the credential.
277279 # This will be supported in the future.
278- resource_ref : Optional [ str ] = None
280+ resource_ref : str | None = None
279281
280- api_key : Optional [ str ] = None
281- http : Optional [ HttpAuth ] = None
282- service_account : Optional [ ServiceAccount ] = None
283- oauth2 : Optional [ OAuth2Auth ] = None
282+ api_key : str | None = None
283+ http : HttpAuth | None = None
284+ service_account : ServiceAccount | None = None
285+ oauth2 : OAuth2Auth | None = None
0 commit comments