Skip to content

fix(bqjdbc): add Google Driver scope to all credential types#12847

Open
Neenu1995 wants to merge 11 commits intomainfrom
ns/fix-driver-scope
Open

fix(bqjdbc): add Google Driver scope to all credential types#12847
Neenu1995 wants to merge 11 commits intomainfrom
ns/fix-driver-scope

Conversation

@Neenu1995
Copy link
Copy Markdown
Contributor

@Neenu1995 Neenu1995 commented Apr 17, 2026

b/500748880

@Neenu1995 Neenu1995 requested review from a team as code owners April 17, 2026 23:26
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 refactors the handling of the RequestGoogleDriveScope property in BigQueryJdbcOAuthUtility. The property is now processed globally and applied across all credential types, including Service Account, User Account, Pre-generated tokens, Application Default Credentials, and External Account authentication. The implementation standardizes the logic for adding the Google Drive read-only scope using boolean string checks and includes corresponding test updates. Feedback was provided regarding the duplication of hardcoded scope lists across multiple methods, suggesting they be moved to a shared utility class for better maintainability.

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.

If generic GoogleCredentials allows to createScoped(), can we add scope modification here instead of doing it for every type of auth separately?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Done.

static final String DRIVE_READONLY_SCOPE = "https://www.googleapis.com/auth/drive.readonly";

static final List<String> DEFAULT_SCOPES = Arrays.asList(BIGQUERY_SCOPE);
static final List<String> DRIVE_SCOPES = Arrays.asList(BIGQUERY_SCOPE, DRIVE_READONLY_SCOPE);
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.

nit: BIGQUERY_WITH_DRIVE_SCOPES?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

done.

"release_level": "stable",
"transport": "both",
"language": "java",
"repo": "googleapis/google-cloud-java",
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.

Why editing iam-policy files?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

It is from a git merge. Not a file change made in this PR. Not sure why the file is in the changelist.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Reverted the file change to remove from PR.


Integer reqGoogleDriveScope = ds.getRequestGoogleDriveScope();
if (reqGoogleDriveScope != null) {
Boolean reqGoogleDriveScopeBool =
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.

I also don't like using magic string & comparing it for bool property.. Should we use retrieve bool at Connection layer from ds & pass bool directly to getCredentials()?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Done

Comment on lines +390 to +394
if ("true"
.equals(
authProperties.get(
BigQueryJdbcUrlUtility.REQUEST_GOOGLE_DRIVE_SCOPE_PROPERTY_NAME))) {
builder.setScopes(DRIVE_SCOPES);
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.

Maybe we can put this logic in a private helper method and use that in all the places unless we can do what @logachev said:

If generic GoogleCredentials allows to createScoped(), can we add scope modification here instead of doing it for every type of auth separately?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Done. As per Kirill's suggestion.

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.

4 participants