Crate google_jwt_auth

Source
Expand description

Crate google-jwt-auth

This crate provides the functionality to create authentication tokens for Google requests.

§Two easy steps to obtain a token:

  1. Create an AuthConfig instance with AuthConfig::build()
  2. Generate a token with AuthConfig::generate_auth_token()

§Example

use google_jwt_auth::AuthConfig;
use google_jwt_auth::usage::Usage;

// Step one: Create AuthConfig
let client_json = std::fs::read_to_string("tests/test-client.json").unwrap();
let usage = Usage::CloudVision;

let config = AuthConfig::build(&client_json, &usage).unwrap();

// Step two: Generate token
let lifetime = 3600_i64;
let token_response = config.generate_auth_token(lifetime);

After awaiting the token_response the result can be obtained.

Modules§

error
This module contains all error types and meanings.
usage
This module contains all types of usages and their description.

Structs§

AuthConfig
This struct contains all necessary information to request an authentication token from Google. This structure is intended to be reused by the client for several token generation requests.

Type Aliases§

Error
This typing is used to have easy access to the library errors.