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-pluginVerified import paths — ran on the pinned version, not inferred.
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.
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`.
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.
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).