{"record":{"id":"e2cbc4eab6a2d296","repo":"BerriAI/litellm","slug":"google-cloud-iam-is-required-for-gcp-iam-redis-aut","errorCode":null,"errorMessage":"google-cloud-iam is required for GCP IAM Redis authentication. Install it with: pip install google-cloud-iam","messagePattern":"google-cloud-iam is required for GCP IAM Redis authentication\\. Install it with: pip install google-cloud-iam","errorType":"exception","errorClass":"ImportError","httpStatus":null,"severity":"error","filePath":"litellm/_redis_credential_provider.py","lineNumber":34,"sourceCode":"# Keyed by service_account → (token, expiry_monotonic_timestamp).\n_token_cache: Final[dict[str, tuple[str, float]]] = {}\n_token_cache_lock: Final = threading.Lock()\n\n\ndef _generate_gcp_iam_access_token(service_account: str) -> str:\n    \"\"\"\n    Generate GCP IAM access token for Redis authentication.\n\n    Args:\n        service_account: GCP service account in format 'projects/-/serviceAccounts/name@project.iam.gserviceaccount.com'\n\n    Returns:\n        Access token string for GCP IAM authentication\n    \"\"\"\n    try:\n        from google.cloud import iam_credentials_v1\n    except ImportError:\n        raise ImportError(\n            \"google-cloud-iam is required for GCP IAM Redis authentication. \"\n            \"Install it with: pip install google-cloud-iam\"\n        )\n\n    client: Final = iam_credentials_v1.IAMCredentialsClient()\n    request: Final = iam_credentials_v1.GenerateAccessTokenRequest(\n        name=service_account,\n        scope=[\"https://www.googleapis.com/auth/cloud-platform\"],\n    )\n    response: Final = client.generate_access_token(request=request)\n    return str(response.access_token)\n\n\ndef _get_cached_gcp_iam_token(service_account: str) -> str:\n    \"\"\"\n    Return a cached GCP IAM token, refreshing only when expired.\n\n    Uses a module-level cache shared across all GCPIAMCredentialProvider","sourceCodeStart":16,"sourceCodeEnd":52,"githubUrl":"https://github.com/BerriAI/litellm/blob/6c2dcb801bf2b75c18f1bb24140e7cf57465cc4d/litellm/_redis_credential_provider.py#L16-L52","documentation":"Error \"google-cloud-iam is required for GCP IAM Redis authentication. Install it with: pip install google-cloud-iam\" thrown in BerriAI/litellm.","triggerScenarios":"Thrown at litellm/_redis_credential_provider.py:34 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Install google-cloud-iam: pip install google-cloud-iam."],"exampleFix":null,"handlingStrategy":null,"validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"6c2dcb801bf2b75c18f1bb24140e7cf57465cc4d","analyzedAt":"2026-08-15T07:12:03.035Z","schemaVersion":2},"datasetVersion":"2026-08-15T17:31:12.345Z"}