Skip to content

feat(google-auth): make _CLOUD_RESOURCE_MANAGER URL universe-domain-aware#16546

Open
baha-zrelli wants to merge 1 commit intogoogleapis:mainfrom
baha-zrelli:feat/external-account-universe-domain-crm-url
Open

feat(google-auth): make _CLOUD_RESOURCE_MANAGER URL universe-domain-aware#16546
baha-zrelli wants to merge 1 commit intogoogleapis:mainfrom
baha-zrelli:feat/external-account-universe-domain-crm-url

Conversation

@baha-zrelli
Copy link
Copy Markdown

Replace hardcoded googleapis.com in _CLOUD_RESOURCE_MANAGER with a {universe_domain} placeholder, resolved at credential construction time via self._cloud_resource_manager_url. This mirrors the existing pattern used for _DEFAULT_TOKEN_URL.

Add tests verifying the URL is correctly built for both the default (googleapis.com) and custom universe domains, including an end-to-end test through get_project_id.

Fixes #16545

…ware

Replace hardcoded googleapis.com in _CLOUD_RESOURCE_MANAGER with a
{universe_domain} placeholder, resolved at credential construction time
via self._cloud_resource_manager_url. This mirrors the existing pattern
used for _DEFAULT_TOKEN_URL.

Add tests verifying the URL is correctly built for both the default
(googleapis.com) and custom universe domains, including an end-to-end
test through get_project_id.
@baha-zrelli baha-zrelli requested review from a team as code owners April 2, 2026 22:13
@google-cla
Copy link
Copy Markdown

google-cla bot commented Apr 2, 2026

Thanks for your pull request! It looks like this may be your first contribution to a Google open source project. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA).

View this failed invocation of the CLA check for more information.

For the most up to date status, view the checks section at the bottom of the pull request.

Copy link
Copy Markdown
Contributor

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

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 updates the external_account module to support custom universe domains for the Cloud Resource Manager URL by parameterizing the base URL and initializing it within the class. Unit tests were added to verify the URL construction for both default and custom domains. A review comment suggests using .format() for URL construction to improve readability and robustness.

if project_number and scopes:
headers = {}
url = _CLOUD_RESOURCE_MANAGER + project_number
url = self._cloud_resource_manager_url + project_number
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.

medium

While the existing code used string concatenation, using an f-string or .format() is generally preferred for URL construction to ensure that the project_number is correctly handled even if it is passed as an integer. This also improves readability.

Suggested change
url = self._cloud_resource_manager_url + project_number
url = "{}{}".format(self._cloud_resource_manager_url, project_number)

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.

feat(google-auth): make Cloud Resource Manager URL universe-domain-aware in external_account credentials

1 participant