diff options
Diffstat (limited to 'src/cpp/client/secure_credentials.cc')
-rw-r--r-- | src/cpp/client/secure_credentials.cc | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/src/cpp/client/secure_credentials.cc b/src/cpp/client/secure_credentials.cc index 19d67c2e06..00245b397d 100644 --- a/src/cpp/client/secure_credentials.cc +++ b/src/cpp/client/secure_credentials.cc @@ -87,6 +87,27 @@ std::shared_ptr<ChannelCredentials> SslCredentials( return WrapChannelCredentials(c_creds); } +namespace experimental { + +// Builds ALTS Credentials given ALTS specific options +std::shared_ptr<ChannelCredentials> AltsCredentials( + const AltsCredentialsOptions& options) { + GrpcLibraryCodegen init; // To call grpc_init(). + grpc_alts_credentials_options* c_options = + grpc_alts_credentials_client_options_create(); + for (auto service_account = options.target_service_accounts.begin(); + service_account != options.target_service_accounts.end(); + service_account++) { + grpc_alts_credentials_client_options_add_target_service_account( + c_options, service_account->c_str()); + } + grpc_channel_credentials* c_creds = grpc_alts_credentials_create(c_options); + grpc_alts_credentials_options_destroy(c_options); + return WrapChannelCredentials(c_creds); +} + +} // namespace experimental + // Builds credentials for use when running in GCE std::shared_ptr<CallCredentials> GoogleComputeEngineCredentials() { GrpcLibraryCodegen init; // To call grpc_init(). |