google-auth

The foundational Python library for authenticating to Google Cloud and Google APIs with OAuth2, service accounts, and Application Default Credentials.

Library
PyPI
v2.62.0
5,412 stars
Apache License 2.0

Repository Health

Pre-computed score based on development activity, maintenance, community, maturity, and trend momentum. How we score it →
98 /100 Excellent
Development Activity 100
Maintenance 96
Community 96
Maturity 60
Momentum 40

Technical Analysis

AI-assessed by reading the actual repository — architecture, code quality, innovation, and documentation. How we score it →
88 /100 Excellent
Architecture 90
Code Quality 92
Innovation 88
Learning Curve 78

google-auth is the core authentication library that underpins nearly every Google client library for Python. It centralizes the many server-to-server and user authentication mechanisms Google supports — service account keys, OAuth2 user flows, Application Default Credentials, workload identity federation, impersonation, and Compute Engine/GKE metadata credentials — behind a single, consistent credential abstraction.

Rather than hand-rolling token minting, signing, and refresh logic against Google’s OAuth2 and STS endpoints, applications obtain a Credentials object and attach it to their HTTP or gRPC transport of choice. The library resolves credentials automatically from the environment, refreshes access tokens transparently, and supports advanced scenarios like downscoped tokens, external account (federated) identities, and mutual-TLS authentication.

What You Get

  • A single Credentials abstraction that works across service accounts, OAuth2 user flows, impersonation, and federated identities
  • Application Default Credentials (ADC) resolution that auto-discovers credentials from env vars, gcloud config, and the metadata server
  • Pluggable transport integrations for requests, urllib3, aiohttp, and gRPC, including async credential support
  • Automatic access-token refresh, JWT minting/signing, mutual-TLS (mTLS) support, and workload identity federation for keyless auth

Common Use Cases

  • Authenticating Google Cloud client libraries (Storage, BigQuery, Pub/Sub) without managing tokens manually
  • Running workloads on GCE, GKE, or Cloud Run that authenticate via the metadata server with zero embedded secrets
  • Federating identities from AWS, Azure, or an OIDC provider into Google Cloud using workload identity federation
  • Impersonating a service account or issuing downscoped, least-privilege tokens for delegated access

Under The Hood

Architecture — The library centers on an abstract Credentials base (google/auth/credentials.py) that every concrete credential type subclasses: oauth2/service_account.py, oauth2/credentials.py (user OAuth2), compute_engine, impersonated_credentials.py, external_account.py, identity_pool.py, aws.py, and api_key.py. Callers rarely instantiate these directly — google/auth/_default.py implements Application Default Credentials, probing environment variables, the gcloud config file (_cloud_sdk.py), and the GCE metadata server in order to resolve a credential. Each credential exposes a refresh(request) method that mints or renews a token against Google’s OAuth2/STS endpoints (oauth2/_client.py, oauth2/sts.py); a _refresh_worker.py enables proactive background renewal. Transport-specific AuthorizedSession/interceptor adapters live under google/auth/transport/ and attach the credential’s token to outgoing HTTP or gRPC calls.

Tech Stack — Pure Python (>=3.10) with a deliberately lean required dependency set: cryptography and pyasn1-modules for signing and ASN.1 parsing. Transport and feature integrations are gated behind extras (requests, aiohttp, urllib3, grpc, pyjwt, reauth, rsa, enterprise_cert) so applications pull in only what they use. Async support is a parallel implementation under google/auth/aio/ and oauth2/_client_async.py. Packaging is classic setup.py with namespace packages and a shipped py.typed marker; tooling includes nox, flake8, mypy, and coverage.

Code Quality — Maturity is high: 69 test modules across tests/ and tests_async/, a py.typed marker signalling full type coverage, and mypy/flake8 configs enforced via noxfile.py. Credential types share a consistent refresh/apply/before_request contract, errors are funneled through a dedicated exceptions.py hierarchy (RefreshError, DefaultCredentialsError, TransportError), and internal helpers are clearly namespaced with leading underscores. A 140KB CHANGELOG and Production/Stable classifier reflect long-term, disciplined maintenance.

API Design — The public surface is small and ergonomic: google.auth.default() returns credentials plus a project id in one call, and __all__ intentionally exposes only default, load_credentials_from_file, and load_credentials_from_dict. The polymorphic Credentials contract means downstream client libraries stay transport- and credential-agnostic, and the requests/gRPC adapters reduce wiring to a couple of lines. The main friction is conceptual rather than API-level — the breadth of credential types (ADC, federation, impersonation, downscoping) demands reading the docs to pick the right one — but everyday usage requires almost no boilerplate.

Used by 151 apps in this directory

Python
51%
AGPL 3.0

Khoj

AI Assistants · Knowledge Management · Productivity

37,802

A self-hostable AI second brain that chats with your documents, searches the web, builds custom agents, and runs entirely on your own LLM.

View details
62
Repo Health
82
Technical
66
Dependency
Built with
Python 51%
TypeScript 36%
Updated 2 months ago
Python
94%
Apache 2.0

knowhere

AI Development · AI Memory · Developer Tools

3,755

Transform messy, unstructured documents into persistent, navigable memory that AI agents can actually use.

View details
83
Repo Health
75
Technical
66
Dependency
Built with
Python 94%
Updated 5 days ago
TypeScript
39%
Apache 2.0

Label Studio

AI Development · Data Engineering

28,540

Label Studio is an open-source, multi-type data labeling platform that lets teams annotate images, text, audio, video, and time series data with a configurable XML-based UI and export annotations in formats ready for any ML framework.

View details
93
Repo Health
87
Technical
64
Dependency
Built with
TypeScript 39%
JavaScript 27%
Python 25%
Updated 6 days ago
TypeScript
39%
Apache 2.0

Label Studio

AI Development · Data Engineering

28,540

Label Studio is an open-source, multi-type data labeling platform that lets teams annotate images, text, audio, video, and time series data with a configurable XML-based UI and export annotations in formats ready for any ML framework.

View details
93
Repo Health
87
Technical
64
Dependency
Built with
TypeScript 39%
JavaScript 27%
Python 25%
Updated 6 days ago
Python
84%
MIT

LiteLLM

AI Development · Developer Tools

61,933

Open source AI gateway and Python SDK that gives you one OpenAI-compatible interface to call 100+ LLM providers, with built-in routing, cost tracking, guardrails, and virtual keys.

View details
93
Repo Health
81
Technical
69
Dependency
Built with
Python 84%
TypeScript 11%
Updated 5 days ago
Python
84%
MIT

LiteLLM

AI Development · Developer Tools

61,933

Open source AI gateway and Python SDK that gives you one OpenAI-compatible interface to call 100+ LLM providers, with built-in routing, cost tracking, guardrails, and virtual keys.

View details
93
Repo Health
81
Technical
69
Dependency
Built with
Python 84%
TypeScript 11%
Updated 5 days ago
Python
58%
Apache 2.0

MLflow

AI Development · Monitoring

28,512

The open source AI engineering platform for debugging, evaluating, monitoring, and optimizing production LLMs and agents at scale.

View details
96
Repo Health
86
Technical
67
Dependency
Built with
Python 58%
TypeScript 35%
Updated 5 days ago
Python
66%
Other

Morphik

AI Development · Databases · Search

3,717

Morphik is an AI-native ingestion and retrieval engine that lets developers store, search, and reason over visually rich documents — scanned PDFs, manuals, slides, and video — without duct-taping together OCR, an embedding model, and a vector database.

View details
64
Repo Health
71
Technical
67
Dependency
Built with
Python 66%
TypeScript 23%
Updated 1 weeks ago
Python
66%
Other

Morphik

AI Development · Databases · Search

3,717

Morphik is an AI-native ingestion and retrieval engine that lets developers store, search, and reason over visually rich documents — scanned PDFs, manuals, slides, and video — without duct-taping together OCR, an embedding model, and a vector database.

View details
64
Repo Health
71
Technical
67
Dependency
Built with
Python 66%
TypeScript 23%
Updated 1 weeks ago

Join founders buildingwith open source

Opinionated takes, migration guides, cost-saving tips, and insights from the open source ecosystem.

Subscribe on Substack
Join 750+ subscribers