Catalog PyPI
PACKAGE EXPLORERView in registry

5x-google-bigquery-auth-manager

PyPI

A simple Python library for creating a Google BigQuery client using either an access token or a service account JSON file.

Versions collected1
Direct dependencies4From release 0.1.2
Last observed20 Oct, 16:05 UTC

README

Version 0.1.2 documentation

5X Google BigQuery Client Authentication Library

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.

  • Preferred Authentication: Access Token (FIVEX_BIGQUERY_ACCESS_TOKEN)
  • Fallback Authentication: Service Account JSON (FIVEX_BIGQUERY_SERVICE_ACCOUNT_KEY)

Installation

Install the package from PyPI using:

pip install 5x-google-bigquery-auth-manager

Environment Variables

This function relies on environment variables for authentication.

VariableDescriptionExample
FIVEX_BIGQUERY_ACCESS_TOKENAccess token for authenticationya29.a0AfH6SMA...
FIVEX_BIGQUERY_DEFAULT_PROJECT_IDYour BigQuery project IDyour-project-id
FIVEX_BIGQUERY_SERVICE_ACCOUNT_KEYPath to the service account JSON key file/path/to/service_account.json

Example: Setting Environment Variables

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"

Usage

Import and Use in Python

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}")

Function Overview

create_bigquery_client()

Creates a BigQuery client using either:

  1. Access Token (Preferred)
  2. Service Account JSON File (Fallback)

How It Works

✔ 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.


Error Handling

This function will raise exceptions in case of failure:

ExceptionCause
ValueErrorNo authentication method found
RefreshErrorAccess token is expired or invalid
GoogleAPICallErrorBigQuery API request failure
BadRequestInsufficient permissions to access BigQuery

Example Handling in Python

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}")

Logging

This function uses Python’s built-in logging module to track:

  • Which authentication method is used (Access Token or Service Account)
  • Errors and exceptions for easier debugging

Why Use This Library?

✔ 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.


Downloads & popularity

Awaiting observations

No metric observations yet

Download counts and popularity will appear here as the collector receives them.

Versions 1

Collected releases
VersionPublishedDirect dependenciesOpen version
0.1.24 Feb 20254

Package advisories

0
No matching advisories collected

This describes our collected data; it is not a security assessment.

Repository

PENDING
5x-platform/5x-nextgen-python-libraries

Shared repository data · GitHub

License detected in repository
Not collected

Metadata history

Meaningful changes
Current collected state Current

Observed since 20 Oct, 16:05 UTC

No superseded metadata states collected. Unchanged observations do not create new revisions.

Record identity

package:e4fead2e9ee1c3afda018d437582a378d252a859466e2e2c635a9283fd3af568