Restore api_key.rs to origin/main

This commit is contained in:
Richard Feldman
2025-12-18 20:13:03 -05:00
parent 3373bad23b
commit b4a2dd4c8e

View File

@@ -228,6 +228,10 @@ impl ApiKeyState {
}
impl ApiKey {
pub fn key(&self) -> &str {
&self.key
}
pub fn from_env(env_var_name: SharedString, key: &str) -> Self {
Self {
source: ApiKeySource::EnvVar(env_var_name),
@@ -235,6 +239,16 @@ impl ApiKey {
}
}
pub async fn load_from_system_keychain(
url: &str,
credentials_provider: &dyn CredentialsProvider,
cx: &AsyncApp,
) -> Result<Self, AuthenticateError> {
Self::load_from_system_keychain_impl(url, credentials_provider, cx)
.await
.into_authenticate_result()
}
async fn load_from_system_keychain_impl(
url: &str,
credentials_provider: &dyn CredentialsProvider,