{"record":{"id":"85c7151430bcbcdf","repo":"xtekky/gpt4free","slug":"antigravity-service-account-environment-variable-n","errorCode":null,"errorMessage":"ANTIGRAVITY_SERVICE_ACCOUNT environment variable not set. Please set it or create credentials at {get_antigravity_oauth_creds_path()}","messagePattern":"ANTIGRAVITY_SERVICE_ACCOUNT environment variable not set\\. Please set it or create credentials at (.+?)","errorType":"exception","errorClass":"RuntimeError","httpStatus":null,"severity":"error","filePath":"g4f/Provider/needs_auth/Antigravity.py","lineNumber":412,"sourceCode":"                self._access_token = cached[\"access_token\"]\n                self._expiry = expires_at\n                return  # Use cached token if valid\n\n        # Try loading from cache file or default path\n        path = AntigravityAuthManager.get_cache_file()\n        if not path.exists():\n            path = get_antigravity_oauth_creds_path()\n\n        if path.exists():\n            try:\n                with path.open(\"r\") as f:\n                    creds = json.load(f)\n            except Exception as e:\n                raise RuntimeError(f\"Failed to read OAuth credentials from {path}: {e}\")\n        else:\n            # Parse credentials from environment\n            if \"ANTIGRAVITY_SERVICE_ACCOUNT\" not in self.env:\n                raise RuntimeError(\n                    \"ANTIGRAVITY_SERVICE_ACCOUNT environment variable not set. \"\n                    f\"Please set it or create credentials at {get_antigravity_oauth_creds_path()}\"\n                )\n            creds = json.loads(self.env[\"ANTIGRAVITY_SERVICE_ACCOUNT\"])\n\n        # Store project_id from credentials if available\n        if creds.get(\"project_id\"):\n            self._project_id = creds[\"project_id\"]\n\n        refresh_token = creds.get(\"refresh_token\")\n        access_token = creds.get(\"access_token\")\n        expiry_date = creds.get(\"expiry_date\")  # milliseconds since epoch\n\n        # Use original access token if still valid\n        if access_token and expiry_date:\n            expires_at = expiry_date / 1000\n            if expires_at - now > self.TOKEN_BUFFER_TIME:\n                self._access_token = access_token","sourceCodeStart":394,"sourceCodeEnd":430,"githubUrl":"https://github.com/xtekky/gpt4free/blob/973504e1770928ed5fb82f43da528f441ad9ddc3/g4f/Provider/needs_auth/Antigravity.py#L394-L430","documentation":"RuntimeError raised in Antigravity credential resolution: no credentials file exists at either the cache path or the default path returned by get_antigravity_oauth_creds_path(), AND the ANTIGRAVITY_SERVICE_ACCOUNT environment variable is not set. The message is actionable — it names both accepted sources. This is the entry-point error for 'Antigravity is not configured at all'.","triggerScenarios":"First use of the Antigravity provider with no prior interactive login (no cache file created yet) and no service account configured; the creds file created at a different path than get_antigravity_oauth_creds_path() expects; env var set in a different shell/session than the one running g4f; containerized deployment that forgot to mount creds or pass the env var.","commonSituations":"New users skipping the auth setup step; CI/Docker deployments missing -e ANTIGRAVITY_SERVICE_ACCOUNT=...; env vars set in .env but never exported into the process environment g4f reads.","solutions":["Export the service account JSON: export ANTIGRAVITY_SERVICE_ACCOUNT='{ ...json... }' in the same environment that runs g4f.","Or create the credentials file at the path printed in the message (get_antigravity_oauth_creds_path()) containing the OAuth creds JSON.","Or run the interactive Antigravity login once so the cache file is written for future runs.","For Docker/CI, pass the env var explicitly: docker run -e ANTIGRAVITY_SERVICE_ACCOUNT=... ..."],"exampleFix":"# before\npython app.py  # no creds file, no env var\n\n# after\nexport ANTIGRAVITY_SERVICE_ACCOUNT='{\"refresh_token\":\"...\",\"project_id\":\"...\"}'\npython app.py","handlingStrategy":"validation","validationCode":"import os, pathlib\nconfigured = ('ANTIGRAVITY_SERVICE_ACCOUNT' in os.environ\n              or pathlib.Path(creds_default_path).exists())\nif not configured:\n    raise SystemExit('Configure Antigravity: set ANTIGRAVITY_SERVICE_ACCOUNT or create the creds file')","typeGuard":"def antigravity_configured(env: dict, creds_path) -> bool:\n    return 'ANTIGRAVITY_SERVICE_ACCOUNT' in env or creds_path.exists()","tryCatchPattern":"try:\n    ...\nexcept RuntimeError as e:\n    if 'ANTIGRAVITY_SERVICE_ACCOUNT' in str(e):\n        raise SystemExit('Set ANTIGRAVITY_SERVICE_ACCOUNT=<json> before using Antigravity') from e\n    raise","preventionTips":["Set ANTIGRAVITY_SERVICE_ACCOUNT in the deployment environment (env_files, docker -e, CI secrets).","Check configuration at startup with a clear message instead of failing mid-request.","Document the creds-file fallback path for interactive setups."],"tags":["auth","antigravity","environment","credentials","setup"],"backgroundTag":null,"analyzedSha":"973504e1770928ed5fb82f43da528f441ad9ddc3","analyzedAt":"2026-08-14T23:45:32.408Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}