GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — feat: Support user defined or json defined scopes for impersonated token by lqiu96 · Pull Request #1815 · googleapis/google-auth-library-java

This repository was archived by the owner on May 12, 2026. It is now read-only.

Conversation

@lqiu96

@lqiu96 lqiu96 commented Oct 9, 2025 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Member

See b/450322374 for more information

Changes

  • Updates ImpersonatedCredentials to accept the scopes value from the JSON file
  • User configured scopes takes precedence over the JSON file

Lots of smaller changes in test files from smaller refactors related to create a CLOUD_PLATFORM_SCOPE constant and such.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@product-auto-label product-auto-label Bot added the size: m Pull request size is medium. label Oct 9, 2025
lqiu96 added 3 commits October 10, 2025 11:22
@lqiu96
feat: Support user defined or json defined scopes for impersonated token
a3d3b86
@lqiu96
chore: Remove wildcard imports
dd215fc
@lqiu96
chore: Clean up PR
7705a7b
@lqiu96
lqiu96 force-pushed the impersonated-cred-scopes branch from 4ec205f to 7705a7b Compare October 10, 2025 15:23
lqiu96 added 3 commits October 10, 2025 11:50
@lqiu96
chore: Create CLOUD_PLATFORM_SCOPE constant in Oauth2Utils
3908a3e
@lqiu96
chore: Fix constant usage in tests
902b6ce
@lqiu96
chore: Fix lint issues
1e7f404
@sonarqubecloud

sonarqubecloud Bot commented Oct 10, 2025

Copy link
Copy Markdown

Quality Gate Failed Quality Gate failed

Failed conditions
0.0% Coverage on New Code (required ≥ 80%)

See analysis details on SonarQube Cloud

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

lqiu96
lqiu96 commented Oct 10, 2025
View reviewed changes
Comment thread oauth2_http/java/com/google/auth/oauth2/ImpersonatedCredentials.java
Comment on lines +406 to +408
if (json.containsKey("scopes")) {
scopes = ImmutableList.copyOf((List<String>) json.get("scopes"));
}

@lqiu96 lqiu96 Oct 10, 2025

Copy link
Copy Markdown
Member Author

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

This scopes field was recently added and may not exist in existing ImpersonatedCred Json files. Check if it exists

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
lqiu96
lqiu96 commented Oct 10, 2025
View reviewed changes
Comment thread oauth2_http/java/com/google/auth/oauth2/ImpersonatedCredentials.java
*/
@CanIgnoreReturnValue
public Builder setScopes(List<String> scopes) {
Preconditions.checkNotNull(scopes, "Scopes cannot be null");

@lqiu96 lqiu96 Oct 10, 2025

Copy link
Copy Markdown
Member Author

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

Constructor has a null check that threw a IllegalStateException runtime exception. Enforce this on the setter so users don't pass in an invalid data.

This never worked, so we don't expect any breakages or changes in behavior.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@lqiu96
lqiu96 marked this pull request as ready for review October 10, 2025 16:10
@lqiu96
lqiu96 requested review from a team and zhumin8 October 10, 2025 16:10
zhumin8
zhumin8 approved these changes Oct 13, 2025
View reviewed changes

@zhumin8 zhumin8 left a comment

Copy link
Copy Markdown
Contributor

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

Change LGTM.
Got question about CLOUD_PLATFORM_SCOPE used for sourceCredentials, but I think it does not block this change.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
Comment thread oauth2_http/java/com/google/auth/oauth2/ImpersonatedCredentials.java
this.sourceCredentials =
this.sourceCredentials.createScoped(Arrays.asList(CLOUD_PLATFORM_SCOPE));
this.sourceCredentials.createScoped(
Collections.singletonList(OAuth2Utils.CLOUD_PLATFORM_SCOPE));

@zhumin8 zhumin8 Oct 13, 2025

Copy link
Copy Markdown
Contributor

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

Does it work or is it better to switch to https://www.googleapis.com/auth/iam?

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions

@lqiu96 lqiu96 Oct 13, 2025 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Member Author

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

I think either should work: https://cloud.google.com/iam/docs/reference/credentials/rest/v1/projects.serviceAccounts/generateAccessToken#authorization-scopes

Not sure if there is a preference. I can update if there is.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@lqiu96
lqiu96 merged commit 84fc566 into main Oct 13, 2025
@lqiu96
lqiu96 deleted the impersonated-cred-scopes branch October 13, 2025 20:11
@release-please release-please Bot mentioned this pull request Oct 13, 2025
chore(main): release 1.40.0 #1811
Merged
@release-please release-please Bot mentioned this pull request Dec 11, 2025
chore(protobuf-4.x-rc): release 1.42.0-rc1 #1861
Merged
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Reviewers

1 more reviewer
@zhumin8 zhumin8 zhumin8 approved these changes
Reviewers whose approvals may not affect merge requirements

Uh oh!

There was an error while loading. Please reload this page.

Assignees

No one assigned

Labels

size: m Pull request size is medium.

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

Uh oh!

There was an error while loading. Please reload this page.

2 participants

@lqiu96 @zhumin8
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
You are visitor 01402775 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.