#google-cloud #gcp #google #gcloud #service-account

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

#785 in Authentication

Download history 573/week @ 2024-07-21 419/week @ 2024-07-28 559/week @ 2024-08-04 1022/week @ 2024-08-11 686/week @ 2024-08-18 934/week @ 2024-08-25 1512/week @ 2024-09-01 733/week @ 2024-09-08 453/week @ 2024-09-15 963/week @ 2024-09-22 887/week @ 2024-09-29 712/week @ 2024-10-06 681/week @ 2024-10-13 502/week @ 2024-10-20 455/week @ 2024-10-27 737/week @ 2024-11-03

2,387 downloads per month
Used in 5 crates (4 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.


lib.rs:

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

Example

use gouth::Token;

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

Dependencies

~16–26MB
~468K SLoC