google-auth is the official Google Authentication Library for Python, providing Application Default Credentials (ADC), service account credentials, OAuth2 tokens, JWT signing/verification, ID token support, Workload Identity Federation, and transport integrations for Requests, urllib3, aiohttp, and gRPC. Current stable version is 2.49.1, released as part of the google-cloud-python monorepo with a roughly monthly cadence.
pip install google-authVerified import paths — ran on the pinned version, not inferred.
Demonstrates Application Default Credentials (ADC) via google.auth.default() and explicit service account credentials. Set GOOGLE_APPLICATION_CREDENTIALS to a service account JSON key path, or authenticate locally with `gcloud auth application-default login`.
Ensure cryptography is installed (it is now pulled in automatically). Remove any explicit rsa dependency pins. Do not install the legacy [rsa] extra expecting it to substitute for cryptography.
Remove direct cachetools imports from google-auth credential caching logic. The library now uses its own lightweight internal cache.
Choose one: pip install google-auth[pyopenssl] OR pip install google-auth[enterprise-cert], never both in the same environment.
Always check: assert project is not None, or override with GOOGLE_CLOUD_PROJECT env var, or pass project explicitly to the client.
Always pass scopes=['https://www.googleapis.com/auth/cloud-platform'] (or specific scopes) to google.auth.default(). Alternatively call credentials.with_scopes([...]) on the returned object.
Migrate to google-auth: replace oauth2client imports with google.auth.default() or google.oauth2.service_account.Credentials.
Upgrade to Python 3.10+. If stuck on Python 3.7, pin google-auth<=2.45.0.
Ensure ADC are configured: set GOOGLE_APPLICATION_CREDENTIALS, run `gcloud auth application-default login`, or ensure the application runs on a Google Cloud service with an attached service account.
Ensure ADC is configured correctly. Set GOOGLE_APPLICATION_CREDENTIALS to a service account key file, or run gcloud auth application-default login, or ensure the environment (e.g., GCE, Cloud Run, Cloud Functions) has an appropriate service account attached.