{"id":9019,"library":"google-cloud-jupyter-config","title":"Google Cloud Jupyter Config","description":"google-cloud-jupyter-config is a Python library that provides utilities for Jupyter environments to retrieve configuration information directly from the Google Cloud SDK (gcloud CLI) and Google Cloud metadata server. It's designed to be a reusable helper for other Jupyter extensions and applications, enabling seamless access to details like project IDs and authentication tokens. The current version is 0.0.12, with releases being infrequent and often tied to the broader 'jupyter-extensions' project.","status":"active","version":"0.0.12","language":"en","source_language":"en","source_url":"https://github.com/GoogleCloudPlatform/jupyter-extensions/tree/master/google-cloud-jupyter-config","tags":["google-cloud","gcp","jupyter","configuration","auth","gcloud"],"install":[{"cmd":"pip install google-cloud-jupyter-config","lang":"bash","label":"Install with pip"}],"dependencies":[{"reason":"This library relies on the `gcloud` command-line tool for configuration retrieval. While not a direct Python dependency, it's a functional requirement for full utility.","package":"google-cloud-sdk","optional":false},{"reason":"Minimum Python version required.","package":"Python >=3.8","optional":false}],"imports":[{"note":"Provides functions like `get_project_id()`.","symbol":"project","correct":"from google_cloud_jupyter_config import project"},{"note":"Provides functions like `get_access_token()` and `get_id_token()`.","symbol":"token","correct":"from google_cloud_jupyter_config import token"},{"note":"Provides utilities for retrieving various gcloud settings.","symbol":"settings","correct":"from google_cloud_jupyter_config import settings"}],"quickstart":{"code":"import os\nfrom google_cloud_jupyter_config import project\nfrom google_cloud_jupyter_config import token\n\n# Ensure gcloud CLI is configured, or environment variables are set\n# For example, by running 'gcloud auth application-default login' or setting GCLOUD_PROJECT\n\nproject_id = project.get_project_id()\nif project_id:\n    print(f\"Google Cloud Project ID: {project_id}\")\nelse:\n    print(\"Could not retrieve Google Cloud Project ID. Is gcloud SDK configured or GCLOUD_PROJECT env var set?\")\n\naccess_token = token.get_access_token()\nif access_token:\n    print(f\"Google Cloud Access Token (first 10 chars): {access_token[:10]}...\")\nelse:\n    print(\"Could not retrieve Google Cloud Access Token. Is gcloud SDK authenticated?\")","lang":"python","description":"This quickstart demonstrates how to retrieve the Google Cloud project ID and an access token using the library. These functions attempt to read from environment variables (e.g., `GCLOUD_PROJECT`), the `gcloud` CLI configuration, and the Google Cloud metadata server (if running on GCP)."},"warnings":[{"fix":"Upgrade to version 0.0.12 or later (`pip install --upgrade google-cloud-jupyter-config`) to ensure tokens are refreshed automatically.","message":"Prior to version 0.0.12, Jupyter sessions integrated with this library could experience authentication token expiration during long-running connections, leading to interrupted workflows.","severity":"gotcha","affected_versions":"<0.0.12"},{"fix":"Ensure the Google Cloud SDK is installed and initialized (e.g., `gcloud init`). Authenticate with `gcloud auth login` or `gcloud auth application-default login` for appropriate credentials.","message":"The library heavily relies on the Google Cloud SDK (gcloud CLI) being installed and correctly configured and authenticated on the system where Jupyter is running. Without it, many utility functions may return `None` or fail.","severity":"gotcha","affected_versions":"All versions"},{"fix":"Always install specific `google-cloud-*` packages like `google-cloud-jupyter-config` directly, rather than the deprecated `google-cloud` package.","message":"The root `google-cloud` PyPI package is deprecated. Users should install product-specific client libraries like `google-cloud-jupyter-config` instead of the umbrella package.","severity":"deprecated","affected_versions":"N/A (affects `google-cloud` not this specific library)"}],"env_vars":null,"last_verified":"2026-04-16T00:00:00.000Z","next_check":"2026-07-15T00:00:00.000Z","problems":[{"fix":"Run `pip install google-cloud-jupyter-config` in your environment. If using a virtual environment, ensure it's activated, or if on a JupyterLab instance, install it into the appropriate kernel environment.","cause":"The `google-cloud-jupyter-config` package is not installed in the Python environment where your Jupyter kernel is running.","error":"ModuleNotFoundError: No module named 'google_cloud_jupyter_config'"},{"fix":"Initialize the Google Cloud SDK by running `gcloud init`. Ensure you are authenticated with `gcloud auth login` or `gcloud auth application-default login`, and a default project is set or `GCLOUD_PROJECT` environment variable is defined.","cause":"The library could not determine the active Google Cloud project ID from environment variables, `gcloud` CLI configuration, or metadata server. This often happens if `gcloud` is not initialized or authenticated.","error":"Could not retrieve Google Cloud Project ID. Is gcloud SDK configured or GCLOUD_PROJECT env var set?"},{"fix":"Verify that the service account or user associated with your Jupyter environment has the required IAM roles and permissions for the Google Cloud project and resources you are trying to access. Use the Google Cloud Console's IAM & Admin section to review and adjust permissions.","cause":"When using `google-cloud-jupyter-config` to retrieve authentication tokens or project details, this error indicates the underlying Google Cloud identity (user or service account) lacks the necessary IAM permissions to access a specific resource or perform an action.","error":"403 Forbidden: The caller does not have permission"}]}