pub struct AuthStore {
pub stored: HashMap<String, StoredCredential>,
/* private fields */
}Expand description
Manages API keys and OAuth credentials.
Fields§
§stored: HashMap<String, StoredCredential>Implementations§
Source§impl AuthStore
impl AuthStore
pub fn new(path: PathBuf) -> Self
Sourcepub fn set_runtime_key(&mut self, provider: &str, key: String)
pub fn set_runtime_key(&mut self, provider: &str, key: String)
Set a runtime override (not persisted). Empty or whitespace-only values are treated as absent.
Sourcepub fn has_credentials(&self, provider: &str) -> bool
pub fn has_credentials(&self, provider: &str) -> bool
Check whether credentials are usable for a provider without producing an error. Returns true if a runtime key, readable stored credential, or env var is available.
Sourcepub fn resolve(&self, provider: &str) -> Result<ApiKey>
pub fn resolve(&self, provider: &str) -> Result<ApiKey>
Resolution order: runtime override -> stored -> env var -> error.
Sourcepub fn resolve_api_key_only(&self, provider: &str) -> Result<ApiKey>
pub fn resolve_api_key_only(&self, provider: &str) -> Result<ApiKey>
Resolve an API key without falling back to stored OAuth credentials.
Sourcepub fn resolve_secret_field(
&self,
provider: &str,
field: &str,
) -> Result<String>
pub fn resolve_secret_field( &self, provider: &str, field: &str, ) -> Result<String>
Resolve a named secret field for any stored provider/service.
Sourcepub fn store_secret_fields(
&mut self,
provider: &str,
fields: HashMap<String, String>,
) -> Result<()>
pub fn store_secret_fields( &mut self, provider: &str, fields: HashMap<String, String>, ) -> Result<()>
Store multiple named secret fields securely in the OS keychain and persist only metadata.
Sourcepub fn secret_status(&self, provider: &str) -> Option<SecretStatus>
pub fn secret_status(&self, provider: &str) -> Option<SecretStatus>
Check whether stored secret metadata points at readable secure-storage values.
Sourcepub fn resolve_secret_fields(
&self,
provider: &str,
) -> Result<HashMap<String, String>>
pub fn resolve_secret_fields( &self, provider: &str, ) -> Result<HashMap<String, String>>
Resolve all stored secret fields for a provider into a map.
Sourcepub async fn resolve_chatgpt_oauth(&mut self) -> Result<ApiKey>
pub async fn resolve_chatgpt_oauth(&mut self) -> Result<ApiKey>
Resolve a ChatGPT/OpenAI OAuth token, preferring openai-codex when present.
pub fn oauth_display_info(&self, provider: &str) -> Option<OAuthDisplayInfo>
Sourcepub fn store(
&mut self,
provider: &str,
credential: StoredCredential,
) -> Result<()>
pub fn store( &mut self, provider: &str, credential: StoredCredential, ) -> Result<()>
Store a credential and persist to disk.
Sourcepub async fn resolve_with_refresh(&mut self, provider: &str) -> Result<ApiKey>
pub async fn resolve_with_refresh(&mut self, provider: &str) -> Result<ApiKey>
Resolve API key, auto-refreshing expired OAuth tokens. Persists the refreshed credential to disk on success.
Sourcepub fn is_oauth_expired(&self, provider: &str) -> bool
pub fn is_oauth_expired(&self, provider: &str) -> bool
Check if the stored OAuth credential for a provider is expired.
Sourcepub fn get_oauth(&self, provider: &str) -> Option<&OAuthCredential>
pub fn get_oauth(&self, provider: &str) -> Option<&OAuthCredential>
Get the stored OAuth credential for a provider (if any).
Sourcepub async fn resolve_or_refresh<F, Fut>(
&mut self,
provider: &str,
refresh_fn: F,
) -> Result<ApiKey>
pub async fn resolve_or_refresh<F, Fut>( &mut self, provider: &str, refresh_fn: F, ) -> Result<ApiKey>
Resolve API key with automatic OAuth refresh.