{"id":5940,"library":"gcs-oauth2-boto-plugin","title":"Google Cloud Storage OAuth 2.0 Boto Plugin","description":"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.","status":"deprecated","version":"3.3","language":"en","source_language":"en","source_url":"https://github.com/GoogleCloudPlatform/gcs-oauth2-boto-plugin","tags":["gcs","google-cloud","boto","oauth","storage","deprecated"],"install":[{"cmd":"pip install gcs-oauth2-boto-plugin","lang":"bash","label":"Install latest version"}],"dependencies":[{"reason":"This plugin extends Boto (v2) for Google Cloud Storage connectivity.","package":"boto","optional":false},{"reason":"Used for OAuth 2.0 credential management and authentication.","package":"oauth2client","optional":false}],"imports":[{"note":"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.","symbol":"gcs_oauth2_boto_plugin","correct":"import gcs_oauth2_boto_plugin"}],"quickstart":{"code":"import os\nimport gcs_oauth2_boto_plugin\nfrom boto.gs.connection import GSConnection\nfrom boto.exception import GSResponseError\n\n# NOTE: This library is DEPRECATED. Use `google-cloud-storage` instead.\n# This example assumes you have authenticated via:\n# `gcloud auth application-default login`\n# or have GOOGLE_APPLICATION_CREDENTIALS pointing to a service account key.\n\nbucket_name = os.environ.get('GCS_BOTO_EXAMPLE_BUCKET', 'your-gcs-boto-example-bucket')\n\nprint(f\"Attempting to connect to GCS using boto with gcs-oauth2-boto-plugin...\")\n\ntry:\n    # After importing gcs_oauth2_boto_plugin, boto will automatically use it.\n    conn = GSConnection()\n\n    # Check if the bucket exists or create it\n    try:\n        bucket = conn.get_bucket(bucket_name)\n        print(f\"Successfully connected to bucket '{bucket_name}'.\")\n    except GSResponseError as e:\n        if e.status == 404:\n            print(f\"Bucket '{bucket_name}' not found, attempting to create...\")\n            bucket = conn.create_bucket(bucket_name)\n            print(f\"Bucket '{bucket_name}' created successfully.\")\n        else:\n            raise\n\n    # Upload a simple string to the bucket\n    key_name = 'hello_boto_gcs.txt'\n    key = bucket.new_key(key_name)\n    key.set_contents_from_string('Hello from gcs-oauth2-boto-plugin!')\n    print(f\"Uploaded '{key_name}' to '{bucket_name}'.\")\n\n    # Download and print the content\n    key_retrieved = bucket.get_key(key_name)\n    if key_retrieved:\n        content = key_retrieved.get_contents_as_string().decode('utf-8')\n        print(f\"Content of '{key_name}': {content}\")\n    else:\n        print(f\"Failed to retrieve '{key_name}'.\")\n\n    # Clean up (optional)\n    # key_retrieved.delete()\n    # print(f\"Deleted '{key_name}'.\")\n\nexcept Exception as e:\n    print(f\"An error occurred: {e}\")\n    print(\"Please ensure you have authenticated to Google Cloud (e.g., `gcloud auth application-default login`) and have correct permissions.\")\n","lang":"python","description":"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."},"warnings":[{"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`.","message":"The `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.","severity":"breaking","affected_versions":"All versions"},{"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.","message":"Relying 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.","severity":"gotcha","affected_versions":"All versions"},{"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).","message":"Authentication 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`.","severity":"gotcha","affected_versions":"All versions"}],"env_vars":null,"last_verified":"2026-04-14T00:00:00.000Z","next_check":"2026-07-13T00:00:00.000Z"}