Skip to content

Commit

Permalink
fix(common): create default gRPC credentials only if needed (#10280)
Browse files Browse the repository at this point in the history
For backwards compatibility with the pre-Unified Credentials world we
were calling `grpc::GoogleDefaultCredentials()` if
`g::c::GrpcCredentialsOption` was not set. In many cases the option is
not set, but `g::c::UnifiedCredentialsOption` is. If that is the case,
the unified options are preferred. Calling
`grpc::GoogleDefaultCredentials()` produces spurious errors, and these
credentials won't be used.
coryan authored Nov 19, 2022

Verified

This commit was signed with the committer’s verified signature.
drashna Drashna Jaelre
1 parent 2cef6b6 commit 6b0a1d7
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion google/cloud/internal/populate_grpc_options.cc
Original file line number Diff line number Diff line change
@@ -29,7 +29,8 @@ Options PopulateGrpcOptions(Options opts, std::string const& emulator_env_var) {
opts.set<GrpcCredentialOption>(grpc::InsecureChannelCredentials());
}
}
if (!opts.has<GrpcCredentialOption>()) {
if (!opts.has<GrpcCredentialOption>() &&
!opts.has<UnifiedCredentialsOption>()) {
opts.set<GrpcCredentialOption>(grpc::GoogleDefaultCredentials());
}
if (!opts.has<GrpcTracingOptionsOption>()) {

0 comments on commit 6b0a1d7

Please sign in to comment.