From e71a6b094ba62a40e2c6fb8f5781c8accf07548a Mon Sep 17 00:00:00 2001 From: yang-g Date: Mon, 10 Aug 2015 15:48:34 -0700 Subject: [PATCH 1/2] call grpc_init for defaultcredentials --- src/cpp/client/secure_credentials.cc | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/cpp/client/secure_credentials.cc b/src/cpp/client/secure_credentials.cc index 2d6114e06b8..68c72c62178 100644 --- a/src/cpp/client/secure_credentials.cc +++ b/src/cpp/client/secure_credentials.cc @@ -34,6 +34,7 @@ #include #include +#include #include "src/cpp/client/channel.h" #include "src/cpp/client/secure_credentials.h" @@ -61,6 +62,7 @@ std::shared_ptr WrapCredentials(grpc_credentials* creds) { } // namespace std::shared_ptr GoogleDefaultCredentials() { + GrpcLibrary init; // To call grpc_init(). return WrapCredentials(grpc_google_default_credentials_create()); } From 9fc755f46520a4c351119728b67f9dd59ab3f20c Mon Sep 17 00:00:00 2001 From: yang-g Date: Mon, 10 Aug 2015 16:39:08 -0700 Subject: [PATCH 2/2] Add to all secure credentials --- src/cpp/client/secure_credentials.cc | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/cpp/client/secure_credentials.cc b/src/cpp/client/secure_credentials.cc index 68c72c62178..6cd6b77fcf5 100644 --- a/src/cpp/client/secure_credentials.cc +++ b/src/cpp/client/secure_credentials.cc @@ -69,6 +69,7 @@ std::shared_ptr GoogleDefaultCredentials() { // Builds SSL Credentials given SSL specific options std::shared_ptr SslCredentials( const SslCredentialsOptions& options) { + GrpcLibrary init; // To call grpc_init(). grpc_ssl_pem_key_cert_pair pem_key_cert_pair = { options.pem_private_key.c_str(), options.pem_cert_chain.c_str()}; @@ -80,6 +81,7 @@ std::shared_ptr SslCredentials( // Builds credentials for use when running in GCE std::shared_ptr ComputeEngineCredentials() { + GrpcLibrary init; // To call grpc_init(). return WrapCredentials(grpc_compute_engine_credentials_create()); } @@ -87,6 +89,7 @@ std::shared_ptr ComputeEngineCredentials() { std::shared_ptr ServiceAccountCredentials( const grpc::string& json_key, const grpc::string& scope, long token_lifetime_seconds) { + GrpcLibrary init; // To call grpc_init(). if (token_lifetime_seconds <= 0) { gpr_log(GPR_ERROR, "Trying to create ServiceAccountCredentials " @@ -102,6 +105,7 @@ std::shared_ptr ServiceAccountCredentials( // Builds JWT credentials. std::shared_ptr ServiceAccountJWTAccessCredentials( const grpc::string& json_key, long token_lifetime_seconds) { + GrpcLibrary init; // To call grpc_init(). if (token_lifetime_seconds <= 0) { gpr_log(GPR_ERROR, "Trying to create JWTCredentials with non-positive lifetime"); @@ -116,6 +120,7 @@ std::shared_ptr ServiceAccountJWTAccessCredentials( // Builds refresh token credentials. std::shared_ptr RefreshTokenCredentials( const grpc::string& json_refresh_token) { + GrpcLibrary init; // To call grpc_init(). return WrapCredentials( grpc_refresh_token_credentials_create(json_refresh_token.c_str())); } @@ -123,6 +128,7 @@ std::shared_ptr RefreshTokenCredentials( // Builds access token credentials. std::shared_ptr AccessTokenCredentials( const grpc::string& access_token) { + GrpcLibrary init; // To call grpc_init(). return WrapCredentials( grpc_access_token_credentials_create(access_token.c_str())); } @@ -131,6 +137,7 @@ std::shared_ptr AccessTokenCredentials( std::shared_ptr IAMCredentials( const grpc::string& authorization_token, const grpc::string& authority_selector) { + GrpcLibrary init; // To call grpc_init(). return WrapCredentials(grpc_iam_credentials_create( authorization_token.c_str(), authority_selector.c_str())); }