Registry / gcp / googleauthentication

googleauthentication

JSON →
library0.0.18pypypiunverified

googleauthentication is a Python meta-package designed to simplify connecting to Google services by bundling and abstracting common patterns from official Google authentication libraries like `google-auth`, `google-auth-oauthlib`, and `google-api-python-client`. It provides helper functions to manage OAuth 2.0 flows for web and installed applications. The current version is 0.0.18, and it maintains an active, iterative release schedule typical for pre-1.0 libraries.

pip install googleauthentication
INSTALL
IMPORT
SIG · GOOGLEAUTHENTICATI
G
googleauthentication
gcppythonv0.0.18
Install
10.6s avg
Import
Disk
89MB
Pass rate
10/ 10
Env Coverage10 / 10
glibc
3.93.13
musl
3.93.13
Install & Compatibility
Where this runs
tested against v0.0.18 · pip install
no network on importno background threads
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
py 3.103.910 runs
installs and imports cleanly · install 0.0s · import 0.000s · 89.5MB
glibc
py 3.103.910 runs
installs and imports cleanly · install 10.6s · import 0.000s · 88MB
89MB installed
● package 89MB
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

build_oauth_session
from googleauthentication.oauth_session import build_oauth_session
from googleauthentication import build_oauth_session
Functions are located in the `oauth_session` submodule, not directly under the top-level package.
build_oauth_service
from googleauthentication.oauth_session import build_oauth_service
from googleauthentication import build_oauth_service
Functions are located in the `oauth_session` submodule, not directly under the top-level package.
OAuthSession
from googleauthentication.oauth_session import OAuthSession
from googleauthentication import OAuthSession
Classes are located in the `oauth_session` submodule, not directly under the top-level package.

This quickstart demonstrates how to use `build_oauth_service` to obtain an authenticated Google API client (e.g., Google Drive). It requires a `client_secrets.json` file (downloaded from the Google Cloud Console for your project) and specifies the necessary OAuth scopes. The example will prompt for browser-based authentication if no valid token is found, then list up to 5 files from your Google Drive. Remember to replace placeholder `YOUR_CLIENT_ID` and `YOUR_CLIENT_SECRET` with actual environment variables or ensure your `client_secrets.json` is correctly configured.

import os import json from googleauthentication.oauth_session import build_oauth_service # --- Create a dummy client_secrets.json for this example --- # In a real scenario, this file is downloaded from Google Cloud Console. # DO NOT hardcode secrets in production code. client_secrets_path = "client_secrets.json" dummy_client_secrets_content = { "web": { "client_id": os.environ.get("GOOGLE_CLIENT_ID", "YOUR_CLIENT_ID"), "project_id": "registry-test-project", "auth_uri": "https://accounts.google.com/o/oauth2/auth", "token_uri": "https://oauth2.googleapis.com/token", "auth_provider_x509_cert_url": "https://www.googleapis.com/oauth2/v1/certs", "client_secret": os.environ.get("GOOGLE_CLIENT_SECRET", "YOUR_CLIENT_SECRET"), "redirect_uris": [ "http://localhost:8080/", "http://localhost" ] } } with open(client_secrets_path, "w") as f: json.dump(dummy_client_secrets_content, f) # --------------------------------------------------------- SCOPES = ['https://www.googleapis.com/auth/drive.metadata.readonly'] TOKEN_FILE = 'token.json' try: # Build an authenticated Google Drive service print("Attempting to build Google Drive service...") drive_service = build_oauth_service( api_name='drive', api_version='v3', client_secrets_json=client_secrets_path, scopes=SCOPES, token_file=TOKEN_FILE ) print("Service built successfully.") # Example: List up to 5 files print("Fetching files...") results = drive_service.files().list( pageSize=5, fields="nextPageToken, files(id, name)").execute() items = results.get('files', []) if not items: print("No files found in your Google Drive.") else: print("Files:") for item in items: print(f" {item['name']} ({item['id']})") except Exception as e: print(f"An error occurred during authentication or API call: {e}") finally: # Clean up dummy files created for the example if os.path.exists(client_secrets_path): os.remove(client_secrets_path) if os.path.exists(TOKEN_FILE): os.remove(TOKEN_FILE) print("Cleanup complete.")
Debug
Known issues
breakingAs a pre-1.0 library (version 0.0.x), `googleauthentication` is subject to frequent and potentially undocumented breaking changes between minor versions. API signatures or internal behaviors may change without strict adherence to semantic versioning.
fix
Pin your `googleauthentication` dependency to a specific version (e.g., `googleauthentication==0.0.18`) in your `requirements.txt` or `pyproject.toml` to prevent unexpected breaks. Regularly check the GitHub repository for updates before upgrading.
affects: <1.0.0
gotchaThe library includes `oauth2client` as a dependency, which is largely deprecated and superseded by `google-auth` and `google-auth-oauthlib` for new development. While `googleauthentication` attempts to integrate them, this mix of legacy and modern libraries could lead to confusion or potential conflicts if other parts of your application rely on specific versions or patterns of Google authentication.
fix
Be aware that while `googleauthentication` provides a convenience layer, deep debugging might require understanding both `google-auth` and `oauth2client` patterns. If you encounter unexpected authentication issues, consider whether conflicts with other Google libraries might be at play.
affects: All versions
gotchaThe official documentation for `googleauthentication` is minimal, relying heavily on understanding the underlying Google client libraries (e.g., `google-auth`, `google-api-python-client`). This can make troubleshooting or advanced usage challenging without prior knowledge of those libraries.
fix
Familiarize yourself with the documentation for `google-auth` and `google-api-python-client` to better understand the authentication flows and API interactions abstracted by `googleauthentication`.
affects: All versions
Upgrade
Version history
0.0.18latest on PyPI · released Oct 9, 2024
Audit
Dependencies
google-authrequiredCore library for Google API authentication.
google-auth-oauthlibrequiredProvides OAuth 2.0 support for Installed Applications and Web Server Applications.
google-api-python-clientrequiredClient library for Google's discovery-based APIs.
google-auth-httplib2requiredAdapter for google-auth to use httplib2.
oauth2clientrequiredLegacy OAuth 2.0 client library; note this library is largely superseded by google-auth for new development.
Agent activity
23 hits · last 30 days
node
18
OpenAI (training)
1
Resources
googleauthentication — pip install googleauthentication · libregistry