#google-api #google #gcp #authentication #google-service #env-var

gauthenticator

Simple API for authenticating with google services Project homepage: https://github.com/isaacadams/bq-rs

2 releases

new 0.2.2 May 27, 2024
0.2.1 May 25, 2024
0.1.6 May 25, 2024
0.1.5 Apr 23, 2024
0.1.2 Nov 25, 2023

#1751 in Web programming

Download history 2/week @ 2024-02-19 10/week @ 2024-02-26 2/week @ 2024-03-11 31/week @ 2024-04-01 302/week @ 2024-04-22 3/week @ 2024-04-29 183/week @ 2024-05-20

192 downloads per month
Used in bq-rs

MIT/Apache

30KB
569 lines

Usage

There are three ways to load authentication credentials for google services.

// 1. load credentials from an environment variable
let authentication = gauthenticator::from_environment_variable("SOME_ENV_VAR");
// 2. load credentials from a file path
let authentication = gauthenticator::from_file("/path/to/credentials.json");
// 3. load credentials from your machine's environment using well known locations
let authentication = gauthenticator::from_env().authentication();

let Some(authentication) = authentication else {
    panic!("failed to find credentials");
};

// log out the authentication details
log::debug!("{}", authentication.message());

// load project id from user input or from the service account file
let project_id = authentication.project_id().expect("project id is required");

// create the bearer token
let token = authentication.token(None)?;

Dependencies

~11–20MB
~396K SLoC