Source code for cadrumo.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.active_profile.resolve_active_profile` obtainsthat profile's immutable bucket UUID through:func:`core.bucket_pointer.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.errors.GoogleAuthProfileUnboundError` so the CLIand storage factory render the same localised repair guidance."""from__future__importannotationsfrom....core.bucket_pointerimportresolve_active_bucket_idfrom....core.operator_action_enumsimportActionEvidenceProvenance,NoRecoveryOutcomefrom.errorsimportGoogleAuthPreconditionCondition,GoogleAuthProfileUnboundError,google_auth_no_action_verdict
[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.errors.GoogleAuthProfileUnboundError`: When the :func:`core.bucket_pointer.resolve_active_bucket_id` precedence chain resolves to no profile. The error carries factual context 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""},translated_message="adapters.google.profile_binding.errors.no_active_profile",precondition_verdict=google_auth_no_action_verdict(condition=GoogleAuthPreconditionCondition.ACTIVE_PROFILE_RESOLVED,facts={"active_profile_resolved":False},provenance=ActionEvidenceProvenance.APPLICATION_STATE,outcome=NoRecoveryOutcome.OPERATOR_DECISION,),)