{"record":{"id":"f763f5b0ec846511","repo":"mem0ai/mem0","slug":"google-auth-is-required-for-gcp-authentication-in","errorCode":null,"errorMessage":"google-auth is required for GCP authentication. Install with: pip install google-auth","messagePattern":"google-auth is required for GCP authentication\\. Install with: pip install google-auth","errorType":"exception","errorClass":"ImportError","httpStatus":null,"severity":"error","filePath":"mem0/utils/gcp_auth.py","lineNumber":10,"sourceCode":"import os\nimport json\nfrom typing import Optional, Dict, Any\n\ntry:\n    from google.oauth2 import service_account\n    from google.auth import default\n    import google.auth.credentials\nexcept ImportError:\n    raise ImportError(\"google-auth is required for GCP authentication. Install with: pip install google-auth\")\n\n\nclass GCPAuthenticator:\n    \"\"\"\n    Centralized GCP authentication handler that supports multiple credential methods.\n\n    Priority order:\n    1. service_account_json (dict) - In-memory service account credentials\n    2. credentials_path (str) - Path to service account JSON file\n    3. Environment variables (GOOGLE_APPLICATION_CREDENTIALS)\n    4. Default credentials (for environments like GCE, Cloud Run, etc.)\n    \"\"\"\n\n    @staticmethod\n    def get_credentials(\n        service_account_json: Optional[Dict[str, Any]] = None,\n        credentials_path: Optional[str] = None,\n        scopes: Optional[list] = None","sourceCodeStart":1,"sourceCodeEnd":28,"githubUrl":"https://github.com/mem0ai/mem0/blob/001c235229be8795e3834520467bd0d661ed8f34/mem0/utils/gcp_auth.py#L1-L28","documentation":"Raised at import time of mem0.utils.gcp_auth when the google-auth package is not installed. The module unconditionally imports google.oauth2.service_account and google.auth in a try/except and converts ImportError into this actionable message. Anything that pulls in a GCP-related provider (Vertex AI embedder, Vertex AI vector search, Gemini via service account) will fail at import with this error.","triggerScenarios":"Importing mem0.embeddings.vertexai or mem0.vector_stores.vertex_ai_vector_search (which transitively import gcp_auth) in an environment without google-auth; a fresh install of mem0ai without extras; a CI image that only installs the core package.","commonSituations":"Using Vertex AI config without installing GCP extras; dependency conflicts where pip resolved google-auth out; multiple virtualenvs and running from the wrong one.","solutions":["pip install google-auth in the active environment","Better: install the provider's full extra, e.g. pip install 'mem0ai[google]' or add google-auth to requirements.txt alongside the vertexai packages","Verify with python -c \"import google.oauth2.service_account\"","If using Docker, rebuild the image after adding the dependency"],"exampleFix":"# before: ImportError: google-auth is required ...\nfrom mem0 import Memory\n\n# after\n# pip install google-auth google-cloud-aiplatform\nfrom mem0 import Memory","handlingStrategy":"validation","validationCode":"import importlib.util\nif importlib.util.find_spec('google.oauth2.service_account') is None:\n    raise ConfigError('google-auth missing — pip install google-auth before using GCP providers')","typeGuard":null,"tryCatchPattern":"try:\n    from mem0.utils import gcp_auth\nexcept ImportError as e:\n    if 'google-auth is required' in str(e):\n        raise ConfigError('add google-auth to requirements') from e\n    raise","preventionTips":["Declare google-auth (and vertexai/genai) in requirements whenever GCP providers are configured","Fail dependency checks at container build time, not request time","Keep one requirements file per deployment target so extras are not forgotten"],"tags":["dependencies","gcp","import","installation"],"backgroundTag":null,"analyzedSha":"001c235229be8795e3834520467bd0d661ed8f34","analyzedAt":"2026-08-15T01:55:42.685Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}