#google #cloud #auth #gcp #gcloud

gouth

This library provides auto-renewed tokens for GCP service authentication

3 releases

✓ Uses Rust 2018 edition

0.1.2 Jun 28, 2020
0.1.1 May 11, 2020
0.1.0 May 4, 2020

#63 in Authentication

27 downloads per month
Used in 2 crates (via secret-keeper-cloudkms)

MIT and MPL-2.0 licenses

26KB
680 lines

gouth

ci Rust Documentation Latest Version

This library provides auto-renewed tokens for GCP service authentication.

Notes

Authentication flow Status
API key Not support / No plans to support
OAuth 2.0 client Supported
Environment-provided service account Supported
Service account key Supported

Example

Default

  • Scope is https://www.googleapis.com/auth/cloud-platform
  • Looks for credentials in the following places, preferring the first location found:
    • A JSON file whose path is specified by the GOOGLE_APPLICATION_CREDENTIALS environment variable.
    • A JSON file in a location known to the gcloud command-line tool.
    • On Google Compute Engine, it fetches credentials from the metadata server.
use gouth::Token;

let token = Token::new().unwrap();
println!("authorization: {}", token.header_value().unwrap());

Custom

scope:

use gouth::Builder;

let token = Builder::new()
	.scopes(&["https://www.googleapis.com/auth/bigquery"])
	.build()
	.unwrap();
println!("authorization: {}", token.header_value().unwrap());

json:

use gouth::Builder;

let token = Builder::new().json("credentials-data").build().unwrap();
println!("authorization: {}", token.header_value().unwrap());

file:

use gouth::Builder;

let token = Builder::new().file("credentials-path").build().unwrap();
println!("authorization: {}", token.header_value().unwrap());

License

Licensed under MIT license.

Dependencies

~15MB
~370K SLoC