lib_client_trello/
auth.rs1use async_trait::async_trait;
2use reqwest::header::HeaderMap;
3
4use crate::error::Result;
5
6#[async_trait]
7pub trait AuthStrategy: Send + Sync {
8 fn query_params(&self) -> Vec<(&'static str, String)>;
9
10 async fn apply(&self, _headers: &mut HeaderMap) -> Result<()> {
11 Ok(())
12 }
13}
14
15#[derive(Debug, Clone)]
17pub struct ApiKeyAuth {
18 api_key: String,
19 token: String,
20}
21
22impl ApiKeyAuth {
23 pub fn new(api_key: impl Into<String>, token: impl Into<String>) -> Self {
24 Self {
25 api_key: api_key.into(),
26 token: token.into(),
27 }
28 }
29}
30
31#[async_trait]
32impl AuthStrategy for ApiKeyAuth {
33 fn query_params(&self) -> Vec<(&'static str, String)> {
34 vec![
35 ("key", self.api_key.clone()),
36 ("token", self.token.clone()),
37 ]
38 }
39}