Source code for aeat.adapters.outbound.google._errors
"""Typed exception hierarchy for the Google OAuth Desktop integration.Every subclass is an :class:`core.errors.AeatError` with a stable:class:`core.errors.ErrorCode` declared in the adapter error registry.That keeps the public CLI taxonomy explicit while:mod:`entrypoints.cli._config._google_errors` can map concrete:class:`GoogleAuthError` subclasses to localised refusal text. Constructorscarry structured remediation context (``context={...}``) so renderers cansurface actionable guidance without leaking the secret material handled by:mod:`adapters.outbound.google._oauth_flow`."""from__future__importannotationsfrom....core.errorsimportAeatError
[docs]classGoogleAuthError(AeatError):"""Base class for every Google OAuth Desktop authentication failure. Catch this at CLI boundaries that need one Google-auth refusal arm while preserving the concrete :class:`core.errors.ErrorCode` on each leaf. """
[docs]classGoogleAuthValidationError(GoogleAuthError):"""Raised when input parameters fail validation."""
[docs]classGoogleAuthClientNotRegisteredError(GoogleAuthError):"""Raised when no Cloud Console Desktop OAuth client is registered for the active profile."""
[docs]classGoogleAuthClientRevokedError(GoogleAuthError):"""Raised when the operator (or Google) revoked the registered Desktop OAuth client."""
[docs]classGoogleAuthRevokedError(GoogleAuthError):"""Raised when the refresh token was revoked (e.g. via myaccount.google.com). Maps to Google's ``invalid_grant`` response with ``error_description="Token has been expired or revoked."``. """
[docs]classGoogleAuthExpiredError(GoogleAuthError):"""Raised when a Testing-project refresh token has aged past Google's 7-day cap."""
[docs]classGoogleAuthScopeInsufficientError(GoogleAuthError):"""Raised when the granted scope set does not include every scope required by the call site."""
[docs]classGoogleAuthNetworkError(GoogleAuthError):"""Raised when the OAuth or token endpoint is unreachable (DNS, TLS, timeout, refused)."""
[docs]classGoogleAuthLoopbackBindError(GoogleAuthError):"""Raised when the loopback HTTP receiver cannot bind a local port."""
[docs]classGoogleAuthBrowserOpenError(GoogleAuthError):"""Raised when the OS-default browser launcher fails to open the consent URL."""
[docs]classGoogleAuthNonInteractiveError(GoogleAuthError):"""Raised when the interactive browser consent flow is attempted without a controlling terminal. The Desktop OAuth flow opens the consent screen in a browser and then blocks a loopback HTTP receiver until the operator completes consent. With no controlling TTY (a piped, redirected, or detached invocation) no operator can complete the flow, so the receiver would block forever. This refusal fails fast instead, naming the interactive-terminal prerequisite. """
[docs]classGoogleAuthUnsecuredModeRefusedError(GoogleAuthError):"""Raised on OAuth attempts under ``aeat_secret_store_backend=unsecured`` with a real NIF profile."""
[docs]classGoogleAuthKeychainLockedError(GoogleAuthError):"""Raised when the OS keychain backing the secret store is locked or unreachable."""
[docs]classGoogleAuthProfileUnboundError(GoogleAuthError):"""Raised when Google auth cannot resolve the active AEAT profile. Emitted by :func:`adapters.outbound.google._active_profile.resolve_active_profile` and profile-loading guards in :mod:`adapters.outbound.google._oauth_flow`. """