Observed since 20 Oct, 16:05 UTC
No superseded metadata states collected. Unchanged observations do not create new revisions.
A simple Python library for creating a Google BigQuery client using either an access token or a service account JSON file.
This Python library provides a simple way to create a Google BigQuery client using either an access token or a service account JSON file. It handles authentication seamlessly, allowing developers to focus on querying BigQuery.
FIVEX_BIGQUERY_ACCESS_TOKEN)FIVEX_BIGQUERY_SERVICE_ACCOUNT_KEY)Install the package from PyPI using:
pip install 5x-google-bigquery-auth-manager
This function relies on environment variables for authentication.
| Variable | Description | Example |
|---|---|---|
FIVEX_BIGQUERY_ACCESS_TOKEN | Access token for authentication | ya29.a0AfH6SMA... |
FIVEX_BIGQUERY_DEFAULT_PROJECT_ID | Your BigQuery project ID | your-project-id |
FIVEX_BIGQUERY_SERVICE_ACCOUNT_KEY | Path to the service account JSON key file | /path/to/service_account.json |
export FIVEX_BIGQUERY_ACCESS_TOKEN="your-access-token"
export FIVEX_BIGQUERY_DEFAULT_PROJECT_ID="your-project-id"
export FIVEX_BIGQUERY_SERVICE_ACCOUNT_KEY="/path/to/service_account.json"
from bigquery_auth import create_bigquery_client
try:
client = create_bigquery_client()
print("✅ BigQuery Client Created Successfully!")
except Exception as e:
print(f"❌ Error: {e}")
create_bigquery_client()Creates a BigQuery client using either:
✔ First, tries to authenticate using the access token (FIVEX_BIGQUERY_ACCESS_TOKEN).
✔ If the access token is expired or invalid, it raises an exception.
✔ If no access token is available, it attempts authentication via service account JSON.
✔ Implements logging and error handling for seamless debugging.
This function will raise exceptions in case of failure:
| Exception | Cause |
|---|---|
ValueError | No authentication method found |
RefreshError | Access token is expired or invalid |
GoogleAPICallError | BigQuery API request failure |
BadRequest | Insufficient permissions to access BigQuery |
try:
client = create_bigquery_client()
except RefreshError as e:
print(f"❌ Token Error: {e}")
except ValueError as e:
print(f"❌ Configuration Error: {e}")
except GoogleAPICallError as e:
print(f"❌ BigQuery API Error: {e}")
except BadRequest as e:
print(f"❌ Permission Error: {e}")
This function uses Python’s built-in logging module to track:
✔ Simplifies Google BigQuery authentication – No need to manage authentication manually.
✔ Supports both Access Tokens & Service Account authentication – Provides flexibility.
✔ Ensures proper error handling – Avoids silent failures with meaningful error messages.
✔ Easy to integrate into any project – Just install and use.
Download counts and popularity will appear here as the collector receives them.
| Version | Published | Direct dependencies | Open version |
|---|---|---|---|
| 0.1.2 | 4 Feb 2025 | 4 |
This describes our collected data; it is not a security assessment.
Shared repository data · GitHub
Observed since 20 Oct, 16:05 UTC
No superseded metadata states collected. Unchanged observations do not create new revisions.
package:e4fead2e9ee1c3afda018d437582a378d252a859466e2e2c635a9283fd3af568