Skip to content

Commit 6b0a1d7

Browse files
authored
fix(common): create default gRPC credentials only if needed (#10280)
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.
1 parent 2cef6b6 commit 6b0a1d7

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

google/cloud/internal/populate_grpc_options.cc

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,8 @@ Options PopulateGrpcOptions(Options opts, std::string const& emulator_env_var) {
2929
opts.set<GrpcCredentialOption>(grpc::InsecureChannelCredentials());
3030
}
3131
}
32-
if (!opts.has<GrpcCredentialOption>()) {
32+
if (!opts.has<GrpcCredentialOption>() &&
33+
!opts.has<UnifiedCredentialsOption>()) {
3334
opts.set<GrpcCredentialOption>(grpc::GoogleDefaultCredentials());
3435
}
3536
if (!opts.has<GrpcTracingOptionsOption>()) {

0 commit comments

Comments
 (0)