Struct google_jwt_auth::AuthConfig
source · pub struct AuthConfig { /* private fields */ }Implementations§
source§impl AuthConfig
impl AuthConfig
sourcepub fn build(service_account_json_str: String, usage: String) -> Result<Self>
pub fn build(service_account_json_str: String, usage: String) -> Result<Self>
This function generates an auth configuration with the provided information. A this config is used to request auth_tokens. This function generates only tokens with the RS256 encryption like the google jwt authentication service does.
Params
service_account_json_str: String
Each google service account has a json file that can be downloaded in the google console during the key generation.
This json file cannot be downloaded twice! A new key must be generated, if the file gets lost!
The content of this file needs to be provided by this param as string.
usage: String
Each google api request requires individual permissions to be executed.
Beside the service account permission a usage or a scope should be provided.
See here for more information: URL.
lifetime: u16
An auth_token has a limited lifetime to am maximum of 3600 seconds.
This value should be between 30 and 3600 Seconds.
Inputs out of this ranged will not be accepted.
Errors
See [TokenGenerationError] for a more detailed answer.
Returns
The above mentioned jwt as String.
sourcepub async fn generate_auth_token(&self, lifetime: i64) -> Result<String>
pub async fn generate_auth_token(&self, lifetime: i64) -> Result<String>
With the provided jwt token, an authentication token (short: auth_token) will be requested from google. This auth_token will be returned and is used for requesting several google api services.
Errors
See [TokenGenerationError] for a more detailed answer.
Returns
The above mentioned auth_token as String.