Source code for aeat.adapters.outbound.google._active_profile
"""Active-profile resolver for the Google OAuth Desktop integration.Every ``aeat config google ...`` command and every secure-store read or writeperformed by :mod:`adapters.outbound.google._oauth_flow` and:mod:`adapters.outbound.google._session_store` is scoped to one AEATprofile. :func:`adapters.outbound.google.resolve_active_profile` obtainsthat profile's immutable bucket UUID through:func:`core.resolve_active_bucket_id`, the operator-facing precedencechain driven by :class:`core.config.Settings` and the plaintextactive-profile pointer file.There is no global Google session, no shared cross-profile token, and nomulti-account binding within a single profile. A missing profile is raised as:exc:`adapters.outbound.google.GoogleAuthProfileUnboundError` so the CLIand storage factory render the same localised repair guidance."""from__future__importannotationsfrom....coreimportresolve_active_bucket_idfrom....core.i18nimporttrfrom._errorsimportGoogleAuthProfileUnboundError
[docs]defresolve_active_profile()->str:"""Return the AEAT profile UUID backing this Google OAuth call. Returns: The resolved profile's immutable UUID identity. Always a non-empty string. Raises: :exc:`adapters.outbound.google.GoogleAuthProfileUnboundError`: When the :func:`core.resolve_active_bucket_id` precedence chain resolves to no profile. The error carries a ``suggestion`` pointing to ``aeat config profile create NAME`` and a ``context`` payload naming the failed resolution attempt for renderers. """resolved=resolve_active_bucket_id()ifresolvedisnotNoneandresolved.strip():returnresolved.strip()raiseGoogleAuthProfileUnboundError("no active AEAT profile bound for Google OAuth",context={"active_profile":resolvedor""},suggestion=tr("adapters.google.profile_binding.suggestions.create_profile"),translated_message="adapters.google.profile_binding.errors.no_active_profile",)