feat: add client_credentials support to prepare_oauth_access_token

This commit is contained in:
2026-07-20 12:44:53 -06:00
parent 4669958bdd
commit aa0270602d
+11 -3
View File
@@ -430,16 +430,24 @@ pub async fn prepare_oauth_access_token(
};
let tokens = if Utc::now().timestamp() >= tokens.expires_at {
refresh_oauth_token(client, provider, client_name, &tokens).await?
match provider.flow() {
OAuthFlow::Pkce => refresh_oauth_token(client, provider, client_name, &tokens).await?,
OAuthFlow::ClientCredentials => {
run_client_credentials_flow(provider, client_name).await?;
load_oauth_tokens(client_name).ok_or_else(|| {
anyhow!("Token file missing after client_credentials refresh")
})?
}
}
} else {
tokens
};
set_access_token(
client_name,
tokens.access_token.clone(),
tokens.access_token,
tokens.expires_at,
tokens.account_id.clone(),
tokens.account_id,
);
Ok(true)