Skip to content

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

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

fix(bqjdbc): add Google Driver scope to all credential types#12847
Neenu1995 wants to merge 6 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.

throw new IllegalStateException(OAUTH_TYPE_ERROR_MESSAGE);
}

return getServiceAccountImpersonatedCredentials(credentials, authProperties);
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?

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?

@@ -10,7 +10,6 @@
"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?


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()?

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.

3 participants