Skip to content

impl(v3): add support for creating OAuth SA creds from files#15887

Merged
scotthart merged 1 commit intogoogleapis:prepare-for-v3.0.0from
scotthart:v3_oauth2_support_sa_file
Jan 20, 2026
Merged

impl(v3): add support for creating OAuth SA creds from files#15887
scotthart merged 1 commit intogoogleapis:prepare-for-v3.0.0from
scotthart:v3_oauth2_support_sa_file

Conversation

@scotthart
Copy link
Copy Markdown
Member

This is the first of a series of PRs (to avoid 1 mega-PR), to decommission the GCS specific OAuth2 API and use the GUAC API instead.

This PR addresses feature parity by porting support for reading service account credentials from JSON and PKCS12 files from the GCS OAuth implementation to the GUAC implementation.

A subsequent PR will rewire the existing GCS OAuth tests for this functionality to use this GUAC implementation.

@scotthart scotthart requested review from a team January 18, 2026 17:43
@gemini-code-assist
Copy link
Copy Markdown

Summary of Changes

Hello @scotthart, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request is a foundational step in transitioning the OAuth2 API from a GCS-specific implementation to the more versatile GUAC API. It introduces the essential capability to load service account credentials from external JSON and PKCS#12 files, ensuring feature parity with the previous system. The changes involve significant internal refactoring to support these file-based configurations consistently across both gRPC and REST transport layers, paving the way for the eventual decommissioning of the older API.

Highlights

  • File-based Service Account Credentials: Added a new public function MakeServiceAccountCredentialsFromFile to create OAuth service account credentials directly from a file path, supporting both JSON and PKCS#12 formats.
  • Refactored ServiceAccountConfig: The internal ServiceAccountConfig class was updated to use absl::optional<std::string> for both JSON content and file path, allowing it to store credentials sourced from either a string or a file.
  • Internal Credential Creation Helpers: Introduced a suite of internal helper functions (CreateServiceAccountCredentialsFromJsonContents, FromJsonFilePath, FromP12FilePath, FromFilePath) to centralize the logic for parsing and creating service account credentials from various sources.
  • Unified Credential Handling: The gRPC and REST credential mapping logic (unified_grpc_credentials.cc and unified_rest_credentials.cc) was updated to correctly interpret and utilize the new file-based service account configurations.
  • Disable Self-Signed JWT Option: Added a DisableSelfSignedJWTOption to provide more granular control over when self-signed JSON Web Tokens (JWTs) are used, particularly for services with stricter requirements like Cloud Storage.

🧠 New Feature in Public Preview: You can now enable Memory to help Gemini Code Assist learn from your team's feedback. This makes future code reviews more consistent and personalized to your project's style. Click here to enable Memory in your admin console.

Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

Copy link
Copy Markdown

@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 is a solid step towards unifying credential handling by adding support for creating service account credentials from files. The changes are well-structured, introducing a new factory function MakeServiceAccountCredentialsFromFile and updating internal configurations to handle either a JSON object string or a file path. The implementation correctly dispatches to file-based loading for both gRPC and REST transports, respecting transport-specific limitations.

I've identified a potential crash in a test utility due to unsafe optional dereferencing, which should be addressed. I've also pointed out a minor code duplication that could be refactored for better maintainability. Overall, this is a good contribution.

Comment thread google/cloud/testing_util/credentials.h Outdated
Comment thread google/cloud/internal/oauth2_service_account_credentials.cc
@codecov
Copy link
Copy Markdown

codecov Bot commented Jan 18, 2026

Codecov Report

❌ Patch coverage is 43.15789% with 54 lines in your changes missing coverage. Please review.
✅ Project coverage is 92.85%. Comparing base (c201e56) to head (e02f3ec).
⚠️ Report is 1 commits behind head on prepare-for-v3.0.0.

Files with missing lines Patch % Lines
...oud/internal/oauth2_service_account_credentials.cc 37.50% 30 Missing ⚠️
google/cloud/internal/unified_grpc_credentials.cc 25.00% 12 Missing ⚠️
google/cloud/internal/unified_rest_credentials.cc 58.33% 5 Missing ⚠️
google/cloud/credentials.cc 25.00% 3 Missing ⚠️
...cloud/storage/internal/unified_rest_credentials.cc 40.00% 3 Missing ⚠️
google/cloud/testing_util/credentials.h 66.66% 1 Missing ⚠️
Additional details and impacted files
@@                  Coverage Diff                   @@
##           prepare-for-v3.0.0   #15887      +/-   ##
======================================================
- Coverage               92.87%   92.85%   -0.03%     
======================================================
  Files                    2391     2391              
  Lines                  218434   218505      +71     
======================================================
+ Hits                   202866   202882      +16     
- Misses                  15568    15623      +55     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@scotthart scotthart force-pushed the v3_oauth2_support_sa_file branch from fb1c0fd to b01f200 Compare January 20, 2026 16:16
@scotthart scotthart force-pushed the v3_oauth2_support_sa_file branch from b01f200 to e02f3ec Compare January 20, 2026 16:43
@scotthart scotthart merged commit d8fe957 into googleapis:prepare-for-v3.0.0 Jan 20, 2026
51 of 52 checks passed
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