Skip to content

feat(auth): support default_host in AsyncAuthorizedSession and secure_authorized_channel - #19195

Open
parthea wants to merge 1 commit into
mainfrom
fix/auth-transport-default-host
Open

parthea wants to merge 1 commit into
mainfrom
fix/auth-transport-default-host

Conversation

@parthea

@parthea parthea commented Nov 24, 2026

Copy link
Copy Markdown
Contributor

Add optional default_host parameter support to AsyncAuthorizedSession and grpc.secure_authorized_channel, matching requests.AuthorizedSession, urllib3.AuthorizedHttp, and grpc.AuthMetadataPlugin for AIP-4111 self-signed JWT initialization:

  • google.auth.aio.transport.sessions.AsyncAuthorizedSession:
    • Accept default_host: Optional[str] = None in __init__.
    • Initialize self-signed JWT credentials for synchronous service_account.Credentials via _create_self_signed_jwt("https://{}/".format(default_host)) (or None when unset), after validating constructor arguments so a failed __init__ does not mutate caller credentials.
  • google.auth.transport.grpc.secure_authorized_channel:
    • Accept default_host=None and forward it to AuthMetadataPlugin(credentials, request, default_host=default_host) without passing it through **kwargs to grpc.secure_channel.
  • Add unit tests covering default_host forwarding, omitted default_host, and non-mutation on constructor failure.

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request introduces support for self-signed JWTs (AIP-4111) in both asynchronous sessions and secure gRPC channels by adding a default_host parameter. In AsyncAuthorizedSession, the default_host is used to configure self-signed JWTs for service account credentials after constructor validation. Similarly, in secure_authorized_channel, the default_host is forwarded to AuthMetadataPlugin to enable minting self-signed JWTs with the intended audience. Corresponding unit tests have been added to verify these behaviors and ensure that failed initialization does not mutate credentials. There are no review comments, and I have no additional feedback to provide.

@parthea
parthea marked this pull request as ready for review November 24, 2026 18:44
@parthea
parthea requested review from a team as code owners November 24, 2026 18:44

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants