rs_firebase_admin_sdk/credentials/gcp/
mod.rs

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
use super::{Credentials, CredentialsError};
use crate::GcpCredentials;
use error_stack::{Report, ResultExt};

impl Credentials for GcpCredentials {
    async fn get_access_token(&self, scopes: &[&str]) -> Result<String, Report<CredentialsError>> {
        let token = self
            .token(scopes)
            .await
            .change_context(CredentialsError::Internal)?;

        Ok(token.as_str().into())
    }

    async fn get_project_id(&self) -> Result<String, Report<CredentialsError>> {
        self.project_id()
            .await
            .change_context(CredentialsError::Internal)
            .map(|t| (*t).to_owned())
    }
}