Update GCP Auth to 0.12

This commit is contained in:
2024-06-04 07:25:01 +01:00
parent 1bd5ab830a
commit 14010f9f78
8 changed files with 68 additions and 100 deletions

View File

@@ -1,7 +1,5 @@
use std::sync::Arc;
use gcp_auth::AuthenticationManager;
use crate::error::Result;
pub trait TokenProvider {
@@ -9,18 +7,10 @@ pub trait TokenProvider {
-> impl std::future::Future<Output = Result<String>> + Send;
}
impl TokenProvider for Arc<AuthenticationManager> {
impl TokenProvider for Arc<dyn gcp_auth::TokenProvider> {
async fn get_token(&self, scope: &[&str]) -> Result<String> {
match AuthenticationManager::get_token(self, scope).await {
Ok(token) => Ok(token.as_str().to_string()),
Err(e) => Err(e.into()),
}
}
}
impl TokenProvider for AuthenticationManager {
async fn get_token(&self, scope: &[&str]) -> Result<String> {
match AuthenticationManager::get_token(self, scope).await {
let token = self.token(scope).await;
match token {
Ok(token) => Ok(token.as_str().to_string()),
Err(e) => Err(e.into()),
}