calesthio/OpenMontage · error · RuntimeError
Service-account auth requires the 'google-auth' package. Ins
Error message
Service-account auth requires the 'google-auth' package. Install it with: pip install google-auth
What it means
RuntimeError raised by the service-account auth helper when the optional google-auth package cannot be imported. The project treats Google auth as an optional dependency, so the import sits inside the function and ImportError is converted into an installable-instruction message surfaced verbatim to the agent/user.
Source
Thrown at tools/google_credentials.py:111
def get_access_token(scopes: list[str] | None = None) -> tuple[str, str | None]:
"""Mint an OAuth access token from the service-account JSON.
Returns ``(access_token, project_id)``. ``project_id`` is the one embedded
in the key file (callers should still prefer :func:`resolve_project_id`).
Raises:
RuntimeError: if ``google-auth`` is missing or the credentials cannot
be loaded/refreshed — with a message the agent can surface verbatim.
"""
if scopes is None:
scopes = [CLOUD_PLATFORM_SCOPE]
try:
from google.auth.transport.requests import Request
from google.oauth2 import service_account
except ImportError as exc: # pragma: no cover - depends on optional dep
raise RuntimeError(
"Service-account auth requires the 'google-auth' package. "
"Install it with: pip install google-auth"
) from exc
path = os.environ.get("GOOGLE_APPLICATION_CREDENTIALS")
if not path or not os.path.exists(path):
raise RuntimeError(
"GOOGLE_APPLICATION_CREDENTIALS is not set or points to a missing "
"file; cannot use service-account authentication."
)
try:
creds = service_account.Credentials.from_service_account_file(
path, scopes=scopes
)
creds.refresh(Request())
except Exception as exc: # noqa: BLE001 - re-raised as actionable message
raise RuntimeError(View on GitHub (pinned to 95e1c3d0ab)
Solutions
- Install it: `pip install google-auth` (plus `google-auth-oauthlib`/`requests` if other flows need them).
- Verify with the same interpreter: `python -c "from google.oauth2 import service_account; print('ok')"`.
- If still failing despite installation, check for a local file/directory named `google.py` or `google/` in the project root shadowing the package; rename it.
- Add google-auth to the project's locked requirements so environments are reproducible.
Example fix
# before RuntimeError: Service-account auth requires the 'google-auth' package. # after (requirements.txt) google-auth>=2.0
Defensive patterns
Strategy: validation
Validate before calling
def google_auth_available() -> bool:
try:
from google.oauth2 import service_account # noqa: F401
return True
except ImportError:
return False Try / catch
try:
token, project = get_service_account_token()
except RuntimeError as e:
if "google-auth" in str(e):
subprocess.run([sys.executable, "-m", "pip", "install", "google-auth"], check=True)
token, project = get_service_account_token() # retry once
else:
raise Prevention
- Include google-auth in deployment requirements from day one.
- Run an import smoke test for optional deps at service startup.
- Avoid local modules named google.py/google/ that shadow the package.
When it happens
Trigger: Calling the service-account token function (get service-account credentials for Google/Gemini scopes) in an environment where `pip install google-auth` was never run, or where google-auth is shadowed by a conflicting package on sys.path.
Common situations: Deployments that installed only google-generativeai or google-genai (which do not always pull google-auth), slim Docker images, multiple virtualenvs, or a local `google/` directory shadowing the installed package.
Related errors
- GOOGLE_APPLICATION_CREDENTIALS is not set or points to a mis
- Failed to load/refresh service-account credentials from {pat
- Service-account credentials did not yield a valid access tok
- No taskId in Suno response: {data}
- Kling identify-face response missing data.session_id: {data}
AI-assisted analysis of calesthio/OpenMontage@95e1c3d0ab (2026-08-15).
Data as JSON: /api/errors/fcd47fb482f04af7.
Report an issue: GitHub.