{"record":{"id":"25fbe23314092eb4","repo":"pola-rs/polars","slug":"google-auth-must-be-installed-to-use-credentialpr","errorCode":null,"errorMessage":"google-auth must be installed to use `CredentialProviderGCP`","messagePattern":"google-auth must be installed to use `CredentialProviderGCP`","errorType":"exception","errorClass":"ImportError","httpStatus":null,"severity":"error","filePath":"py-polars/src/polars/io/cloud/credential_provider/_providers.py","lineNumber":588,"sourceCode":"        creds.refresh(google.auth.transport.requests.Request())  # type: ignore[no-untyped-call, unused-ignore]\n\n        return {\"bearer_token\": creds.token}, (  # type: ignore[dict-item]\n            int(\n                (\n                    expiry.replace(tzinfo=zoneinfo.ZoneInfo(\"UTC\"))\n                    if expiry.tzinfo is None\n                    else expiry\n                ).timestamp()\n            )\n            if (expiry := creds.expiry) is not None\n            else None\n        )\n\n    @classmethod\n    def _ensure_module_availability(cls) -> None:\n        if importlib.util.find_spec(\"google.auth\") is None:\n            msg = \"google-auth must be installed to use `CredentialProviderGCP`\"\n            raise ImportError(msg)\n\n\nclass UserProvidedGCPToken(CredentialProvider):\n    \"\"\"User-provided GCP token in storage_options.\"\"\"\n\n    def __init__(self, token: str) -> None:\n        self.token = token\n\n    def __call__(self) -> CredentialProviderFunctionReturn:\n        return {\"bearer_token\": self.token}, None\n\n\ndef _get_credentials_from_provider_expiry_aware(\n    credential_provider: CredentialProviderFunction,\n) -> dict[str, str] | None:\n    if (\n        isinstance(credential_provider, CredentialProviderAWS)\n        and not credential_provider._can_use_as_provider()","sourceCodeStart":570,"sourceCodeEnd":606,"githubUrl":"https://github.com/pola-rs/polars/blob/df599052daf96e7a9cc30a3b0c6bd25d6947e3c0/py-polars/src/polars/io/cloud/credential_provider/_providers.py#L570-L606","documentation":"CredentialProviderGCP._ensure_module_availability (py-polars/src/polars/io/cloud/credential_provider/_providers.py:583-588) checks importlib.util.find_spec('google.auth') and raises ImportError when the Python GCP credential provider is selected but google-auth is missing. google-auth is optional and powers application-default-credentials resolution on the Python side (e.g. CredentialProviderGCP's default path).","triggerScenarios":"pl.scan_parquet('gs://bucket/f.parquet') with no token/service_account in storage_options on an environment without google-auth and no natively-discoverable ADC; or explicit pl.CredentialProviderGCP().","commonSituations":"Slim containers without the GCP extra; local dev where gcloud ADC is not set up; dependency cleanups that removed a formerly transitive google-auth.","solutions":["pip install google-auth","Give the Rust side a direct credential: storage_options={'service_account': '/path/sa.json'}","Run gcloud auth application-default login so ADC is discoverable"],"exampleFix":"# before\nlf = pl.scan_parquet(\"gs://bucket/f.parquet\")  # ImportError\n# after\n# $ pip install google-auth\nlf = pl.scan_parquet(\"gs://bucket/f.parquet\")","handlingStrategy":"validation","validationCode":"import importlib.util\n\ndef require_google_auth() -> None:\n    if importlib.util.find_spec(\"google.auth\") is None:\n        raise ImportError(\"pip install google-auth for gs:// access without an explicit token\")","typeGuard":null,"tryCatchPattern":"try:\n    lf = pl.scan_parquet(url)\nexcept ImportError as e:\n    if \"google-auth\" in str(e):\n        raise SystemExit(\"pip install google-auth (or set service_account in storage_options)\") from e\n    raise","preventionTips":["Include google-auth where gs:// paths are read","Or standardize on a service_account key in storage_options / workload identity","Check optional cloud dependencies in deployment smoke tests"],"tags":["polars","gcp","google-auth","credentials","importerror","dependencies"],"backgroundTag":null,"analyzedSha":"df599052daf96e7a9cc30a3b0c6bd25d6947e3c0","analyzedAt":"2026-08-16T12:10:03.978Z","schemaVersion":2},"datasetVersion":"2026-08-16T13:17:31.715Z"}