pub trait AuthProvider:
Send
+ Sync
+ 'static {
// Required methods
fn get_api_key(
&self,
provider: &str,
) -> Pin<Box<dyn Future<Output = Result<Option<String>, SdkError>> + Send + '_>>;
fn set_api_key(
&self,
provider: &str,
key: &str,
) -> Pin<Box<dyn Future<Output = Result<(), SdkError>> + Send + '_>>;
fn delete_api_key(
&self,
provider: &str,
) -> Pin<Box<dyn Future<Output = Result<(), SdkError>> + Send + '_>>;
fn get_oauth(
&self,
provider: &str,
) -> Pin<Box<dyn Future<Output = Result<Option<OAuthToken>, SdkError>> + Send + '_>>;
fn set_oauth(
&self,
provider: &str,
token: OAuthToken,
) -> Pin<Box<dyn Future<Output = Result<(), SdkError>> + Send + '_>>;
fn list_providers(
&self,
) -> Pin<Box<dyn Future<Output = Result<Vec<String>, SdkError>> + Send + '_>>;
// Provided method
fn get_api_key_sync(
&self,
_provider: &str,
) -> Result<Option<String>, SdkError> { ... }
}Expand description
Credential provider for LLM providers.
Supports both API key (single string) and OAuth (token bundle) per provider. Storage is implementation-defined (file, keychain, env, etc.).
Required Methods§
Sourcefn get_api_key(
&self,
provider: &str,
) -> Pin<Box<dyn Future<Output = Result<Option<String>, SdkError>> + Send + '_>>
fn get_api_key( &self, provider: &str, ) -> Pin<Box<dyn Future<Output = Result<Option<String>, SdkError>> + Send + '_>>
Read the API key for a provider.
Sourcefn set_api_key(
&self,
provider: &str,
key: &str,
) -> Pin<Box<dyn Future<Output = Result<(), SdkError>> + Send + '_>>
fn set_api_key( &self, provider: &str, key: &str, ) -> Pin<Box<dyn Future<Output = Result<(), SdkError>> + Send + '_>>
Write the API key for a provider.
Sourcefn delete_api_key(
&self,
provider: &str,
) -> Pin<Box<dyn Future<Output = Result<(), SdkError>> + Send + '_>>
fn delete_api_key( &self, provider: &str, ) -> Pin<Box<dyn Future<Output = Result<(), SdkError>> + Send + '_>>
Delete the API key for a provider.
Sourcefn get_oauth(
&self,
provider: &str,
) -> Pin<Box<dyn Future<Output = Result<Option<OAuthToken>, SdkError>> + Send + '_>>
fn get_oauth( &self, provider: &str, ) -> Pin<Box<dyn Future<Output = Result<Option<OAuthToken>, SdkError>> + Send + '_>>
Read the OAuth token bundle for a provider.
Provided Methods§
Sourcefn get_api_key_sync(&self, _provider: &str) -> Result<Option<String>, SdkError>
fn get_api_key_sync(&self, _provider: &str) -> Result<Option<String>, SdkError>
Sync fast-path for reading the API key.
Used by crate::Oxicode::create_provider when constructing a built-in
provider in a sync context (e.g. inside the agent loop’s
ProviderResolver::resolve_provider). The default returns Ok(None)
(no sync source available); implementations with synchronous backing
stores (e.g. crate::ports::fs::FileAuthProvider) override this to
expose their already-synchronous read path without forcing callers
through block_on. This is the credential source the agent loop
consults at provider-construction time, replacing the old
AgentConfig.api_key injection (issue #40).
Dyn Compatibility§
This trait is dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".