djc/gcp_auth


Minimal authentication library for Google Cloud Platform (GCP)

License: Other

Language: Rust

Keywords: auth, authentication, gcp, google-cloud-platform, library, rust


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 in the listed priority order:

  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. Look for credentials in .config/gcloud/application_default_credentials.json; if found, use these credentials to request refresh tokens. This file can be created by invoking gcloud auth application-default login.
  3. Use the default service account by retrieving a token from the metadata server.
  4. Retrieving a token from the gcloud CLI tool, if it is available on the PATH.

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.

Project Statistics

Sourcerank 10
Repository Size 196 KB
Stars 59
Forks 38
Watchers 6
Open issues 7
Dependencies 21
Contributors 16
Tags 6
Created
Last updated
Last pushed

Top Contributors See all

Dirkjan Ochtman Peter Hrvola thrykol MatthewHelmer dependabot[bot] Rudi Floren Floris Bruynooghe Matt Tanous Yong Wen Chua Henrik Sjööh André Cipriani Bandarra Fuyang Liu Jonathon Belotti Dylan McGannon Orne Brocaar Erik Živković

Packages Referencing this Repo

gcp_auth
Google cloud platform (GCP) authentication using default and custom service accounts
Latest release 0.12.2 - Updated - 59 stars

Recent Tags See all

0.12.2 May 29, 2024
0.12.1 May 27, 2024
0.11.0 May 27, 2024
0.11.1 May 27, 2024
0.12.0 May 27, 2024
0.9.0 June 30, 2023

Something wrong with this page? Make a suggestion

Last synced: 2024-05-29 12:05:12 UTC

Login to resync this repository