#google #cloud #auth #gcloud #gcp

gouth

This library provides auto-renewed tokens for GCP service authentication

5 releases

0.2.1 Apr 19, 2021
0.2.0 Feb 12, 2021
0.1.2 Jun 28, 2020
0.1.1 May 11, 2020
0.1.0 May 4, 2020

#402 in Authentication

Download history 228/week @ 2023-01-17 284/week @ 2023-01-24 438/week @ 2023-01-31 353/week @ 2023-02-07 257/week @ 2023-02-14 210/week @ 2023-02-21 254/week @ 2023-02-28 222/week @ 2023-03-07 201/week @ 2023-03-14 427/week @ 2023-03-21 640/week @ 2023-03-28 231/week @ 2023-04-04 375/week @ 2023-04-11 227/week @ 2023-04-18 185/week @ 2023-04-25 219/week @ 2023-05-02

1,050 downloads per month
Used in 4 crates (3 directly)

MIT license

27KB
698 lines

gouth

ci Rust Documentation Latest Version

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

Notes

Authentication flow Status
API key Not supported / 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.
// simple:
// gouth = { version = "x.x.x" }
let token = gouth::Token::new().unwrap();
println!("authorization: {}", token.header_value().unwrap());

// with tonic:
// gouth = { path = "x.x.x", features = ["tonic-intercept"] }
let mut service = PublisherClient::with_interceptor(channel, gouth::tonic::interceptor());
service.list_topics(...);

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

~12–20MB
~464K SLoC