pub struct Config {
pub auth_scheme: Scheme,
pub raw_auth_credential: Option<Credential>,
pub exchanged_auth_credential: Option<Credential>,
pub credential_key: String,
pub extra: Extra,
}Expand description
What a tool needs in order to get a credential: how the resource
authenticates, the credential the tool was configured with, and the credential the flow
produces. ADK sends it to the client in an adk_request_credential call, and the client
fills exchanged_auth_credential in and sends it back.
It reads and writes adk-python’s AuthConfig JSON: each field under its camelCase name,
read under that name or its snake_case Python name (camelCase wins when both are present),
and unknown keys kept in extra. credentialKey is always written, as Config::key.
Fields§
§auth_scheme: SchemeHow the resource authenticates. Required on decode.
raw_auth_credential: Option<Credential>The credential the tool was configured with, such as an OAuth2 client ID and secret. A
scheme that needs no exchange, such as an API key, may leave it None.
exchanged_auth_credential: Option<Credential>Filled in by ADK and the client together. For OAuth2 and OpenID Connect, ADK adds the authorization URI and state, and the client adds the auth response.
credential_key: StringNames the credential in a credential service. Serialized as Config::key.
extra: ExtraJSON keys that match no field, each as the raw text it arrived as.
Implementations§
Source§impl Config
impl Config
Sourcepub fn key(&self) -> String
pub fn key(&self) -> String
The key that names this config’s credential in a credential service.
It is credential_key when that is set. Otherwise it is the first non-empty string
under credential_key or credentialKey among the unknown keys of
raw_auth_credential, then of auth_scheme, which is where adk-python’s AuthConfig
looks. Otherwise it is derived the way adk-python’s get_credential_key derives it:
adk_<type>_<digest>_ followed, when there is a raw credential, by
<authType>_<digest>. Each digest covers the JSON of the scheme or the credential
without its own unknown keys. The OAuth2 fields that change during a flow (auth_uri,
state, auth_response_uri, auth_code, access_token, refresh_token,
expires_at, expires_in and redirect_uri) are left out, so the key stays put while
the flow runs.
Every field of Scheme counts towards the key, whatever its type, but the scheme’s
extra does not. A custom scheme’s own fields are in extra, so two schemes of one
custom type that differ only there get the same key; set credential_key to tell them
apart.
key trusts the config it is called on. A config a client sends back in an
adk_request_credential response can carry any credentialKey, so take only its
exchanged_auth_credential and store the credential under the key of the config ADK
sent, as adk-python’s store_auth_response does.
Infallible: extra holds only valid JSON text, so nothing in it can fail to encode.
Sourcepub fn without_secrets(&self) -> Config
pub fn without_secrets(&self) -> Config
A deep copy of the config without the secrets the agent was configured with, for sending to the client and keeping in the session.
In both raw_auth_credential and exchanged_auth_credential it drops the API key, the
OAuth2 client secret, the HTTP password, token and additional headers, and a service
account’s private key and key ID. That is adk-python’s _without_configured_secrets,
which leaves the service account key in. Everything else, the PKCE code verifier
included, is kept. The copy carries this config’s Config::key in credential_key,
since its stripped content would derive a different one.
The copy shares nothing with self: Clone copies every map, list and extra value.
Infallible, because Config::key is.