19 lines
512 B
Rust
19 lines
512 B
Rust
use std::sync::Arc;
|
|
|
|
use crate::error::Result;
|
|
|
|
pub trait TokenProvider {
|
|
fn get_token(&self, scope: &[&str])
|
|
-> impl std::future::Future<Output = Result<String>> + Send;
|
|
}
|
|
|
|
impl TokenProvider for Arc<dyn gcp_auth::TokenProvider + '_> {
|
|
async fn get_token(&self, scope: &[&str]) -> Result<String> {
|
|
let token = self.token(scope).await;
|
|
match token {
|
|
Ok(token) => Ok(token.as_str().to_string()),
|
|
Err(e) => Err(e.into()),
|
|
}
|
|
}
|
|
}
|