Registry / gcp / gcs-oauth2-boto-plugin

gcs-oauth2-boto-plugin

JSON →
library3.3pypypiunverified

This plugin enables the Boto library (version 2) to authenticate with Google Cloud Storage using OAuth 2.0 credentials, including service accounts and user accounts. It allows legacy Boto applications to interact with GCS. This library is deprecated; users are strongly encouraged to migrate to the official `google-cloud-storage` client library. The last release was 3.3 in March 2021, and the project is no longer actively maintained.

pip install gcs-oauth2-boto-plugin
INSTALL
IMPORT
SIG · GCS-OAUTH2-BOTO-PL
G
gcs-oauth2-boto-plugin
gcppythonv3.3
Install
6.5s avg
Import
1045ms
Disk
54MB
Pass rate
10/ 10
Env Coverage10 / 10
glibc
3.93.13
musl
3.93.13
Install & Compatibility
Where this runs
tested against v3.3 · 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.920 runs
installs and imports cleanly · install 0.0s · import 0.668s · 54.4MB
glibc
py 3.103.920 runs
installs and imports cleanly · install 6.5s · import 0.585s · 55MB
54MB installed
● package 54MB
Code
Verified usage

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

gcs_oauth2_boto_plugin
import gcs_oauth2_boto_plugin
Importing the module initializes the plugin, making Boto aware of GCS OAuth2 authentication methods. No direct classes or functions are typically called from this module by the user.

This example demonstrates how to establish a connection to Google Cloud Storage using the Boto library (v2) with `gcs-oauth2-boto-plugin`. It relies on standard Google Cloud authentication mechanisms like `gcloud auth application-default login` or `GOOGLE_APPLICATION_CREDENTIALS`. It then performs basic operations: connecting, checking/creating a bucket, uploading a file, and downloading its content. Replace 'your-gcs-boto-example-bucket' with an actual bucket name you have access to or create one.

import os import gcs_oauth2_boto_plugin from boto.gs.connection import GSConnection from boto.exception import GSResponseError # NOTE: This library is DEPRECATED. Use `google-cloud-storage` instead. # This example assumes you have authenticated via: # `gcloud auth application-default login` # or have GOOGLE_APPLICATION_CREDENTIALS pointing to a service account key. bucket_name = os.environ.get('GCS_BOTO_EXAMPLE_BUCKET', 'your-gcs-boto-example-bucket') print(f"Attempting to connect to GCS using boto with gcs-oauth2-boto-plugin...") try: # After importing gcs_oauth2_boto_plugin, boto will automatically use it. conn = GSConnection() # Check if the bucket exists or create it try: bucket = conn.get_bucket(bucket_name) print(f"Successfully connected to bucket '{bucket_name}'.") except GSResponseError as e: if e.status == 404: print(f"Bucket '{bucket_name}' not found, attempting to create...") bucket = conn.create_bucket(bucket_name) print(f"Bucket '{bucket_name}' created successfully.") else: raise # Upload a simple string to the bucket key_name = 'hello_boto_gcs.txt' key = bucket.new_key(key_name) key.set_contents_from_string('Hello from gcs-oauth2-boto-plugin!') print(f"Uploaded '{key_name}' to '{bucket_name}'.") # Download and print the content key_retrieved = bucket.get_key(key_name) if key_retrieved: content = key_retrieved.get_contents_as_string().decode('utf-8') print(f"Content of '{key_name}': {content}") else: print(f"Failed to retrieve '{key_name}'.") # Clean up (optional) # key_retrieved.delete() # print(f"Deleted '{key_name}'.") except Exception as e: print(f"An error occurred: {e}") print("Please ensure you have authenticated to Google Cloud (e.g., `gcloud auth application-default login`) and have correct permissions.")
Debug
Known issues
breakingThe `gcs-oauth2-boto-plugin` library and its integration with Boto (v2) for Google Cloud Storage is officially deprecated by Google Cloud. Users are strongly advised to migrate to the `google-cloud-storage` client library for Python.
fix
Migrate your application logic to use the `google-cloud-storage` library. This involves rewriting interactions with GCS objects and buckets using the new client's API. For example, replace `boto.gs.connection.GSConnection` with `google.cloud.storage.Client`.
affects: All versions
gotchaRelying on Boto (v2) for Google Cloud Storage may lead to unexpected behavior or missing features. Boto's S3 compatibility layer for GCS is not 100% feature-complete and may not support newer GCS functionalities.
fix
Avoid using Boto for GCS. If migration is not immediately possible, thoroughly test your application against GCS for expected behavior and be aware of potential limitations. Prioritize migration to the `google-cloud-storage` library.
affects: All versions
gotchaAuthentication with `gcs-oauth2-boto-plugin` requires careful configuration of Boto's `~/.boto` file, environment variables (e.g., `GOOGLE_APPLICATION_CREDENTIALS`), or relying on `gcloud auth application-default login`. Misconfiguration often leads to `GSResponseError: 403 Forbidden` or `401 Unauthorized`.
fix
Ensure your environment is correctly set up for Google Cloud Application Default Credentials, or that your `~/.boto` file contains the correct `gs_oauth2_refresh_token`, `gs_oauth2_client_id`, `gs_oauth2_client_secret` (for user accounts) or `gs_service_key_file`, `gs_service_client_id` (for service accounts).
affects: All versions
Upgrade
Version history
3.3latest on PyPI · released Jun 24, 2025
Audit
Dependencies
botorequiredThis plugin extends Boto (v2) for Google Cloud Storage connectivity.
oauth2clientrequiredUsed for OAuth 2.0 credential management and authentication.
Agent activity
41 hits · last 30 days
node
34
OpenAI (training)
1
Resources
gcs-oauth2-boto-plugin — pip install gcs-oauth2-boto-plugin · libregistry