#authentication #gcp #google

gcp_auth

Google cloud platform (GCP) authentication using default and custom service accounts

22 unstable releases (6 breaking)

0.7.3 Apr 28, 2022
0.7.2 Feb 10, 2022
0.6.2 Jan 22, 2022
0.6.1 Dec 13, 2021
0.1.4 Jul 2, 2020

#11 in Authentication

Download history 2509/week @ 2022-04-20 1913/week @ 2022-04-27 1683/week @ 2022-05-04 3578/week @ 2022-05-11 2323/week @ 2022-05-18 3854/week @ 2022-05-25 4919/week @ 2022-06-01 2777/week @ 2022-06-08 4051/week @ 2022-06-15 3008/week @ 2022-06-22 2740/week @ 2022-06-29 3351/week @ 2022-07-06 3363/week @ 2022-07-13 4822/week @ 2022-07-20 4692/week @ 2022-07-27 3197/week @ 2022-08-03

16,737 downloads per month
Used in 4 crates

MIT license

40KB
712 lines

GCP Auth

Crates.io Documentation MIT licensed

GCP auth provides authentication using service accounts Google Cloud Platform (GCP)

GCP auth is a simple, minimal authentication library for Google Cloud Platform (GCP) providing authentication using service accounts. Once authenticated, the service account can be used to acquire bearer tokens for use in authenticating against GCP services.

The library supports the following methods of retrieving tokens:

  1. Reading custom service account credentials from the path pointed to by the GOOGLE_APPLICATION_CREDENTIALS environment variable. Alternatively, custom service account credentials can be read from a JSON file or string.
  2. Retrieving a token from the gcloud CLI tool, if it is available on the PATH.
  3. Use the default service account by retrieving a token from the metadata server.
  4. Look for credentials in .config/gcloud/application_default_credentials.json; if found, use these credentials to request refresh tokens.

For more detailed information and examples, see the docs.

This crate does not currently support Windows.

Simple usage

The default way to use this library is to get instantiate an AuthenticationManager. It will find the appropriate authentication method and use it to retrieve tokens.

use gcp_auth::AuthenticationManager;

let authentication_manager = AuthenticationManager::new().await?;
let scopes = &["https://www.googleapis.com/auth/cloud-platform"];
let token = authentication_manager.get_token(scopes).await?;

License

Parts of the implementation have been sourced from yup-oauth2.

Licensed under MIT license.

Dependencies

~14–22MB
~497K SLoC