|
|
@ -55,7 +55,8 @@ class SecureCredentials GRPC_FINAL : public Credentials { |
|
|
|
args.SetChannelArgs(&channel_args); |
|
|
|
args.SetChannelArgs(&channel_args); |
|
|
|
return std::shared_ptr<ChannelInterface>(new Channel( |
|
|
|
return std::shared_ptr<ChannelInterface>(new Channel( |
|
|
|
args.GetSslTargetNameOverride().empty() |
|
|
|
args.GetSslTargetNameOverride().empty() |
|
|
|
? target : args.GetSslTargetNameOverride(), |
|
|
|
? target |
|
|
|
|
|
|
|
: args.GetSslTargetNameOverride(), |
|
|
|
grpc_secure_channel_create(c_creds_, target.c_str(), &channel_args))); |
|
|
|
grpc_secure_channel_create(c_creds_, target.c_str(), &channel_args))); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
@ -111,7 +112,7 @@ std::unique_ptr<Credentials> ServiceAccountCredentials( |
|
|
|
|
|
|
|
|
|
|
|
// Builds JWT credentials.
|
|
|
|
// Builds JWT credentials.
|
|
|
|
std::unique_ptr<Credentials> JWTCredentials( |
|
|
|
std::unique_ptr<Credentials> JWTCredentials( |
|
|
|
const grpc::string &json_key, std::chrono::seconds token_lifetime) { |
|
|
|
const grpc::string& json_key, std::chrono::seconds token_lifetime) { |
|
|
|
if (token_lifetime.count() <= 0) { |
|
|
|
if (token_lifetime.count() <= 0) { |
|
|
|
gpr_log(GPR_ERROR, |
|
|
|
gpr_log(GPR_ERROR, |
|
|
|
"Trying to create JWTCredentials with non-positive lifetime"); |
|
|
|
"Trying to create JWTCredentials with non-positive lifetime"); |
|
|
@ -122,6 +123,13 @@ std::unique_ptr<Credentials> JWTCredentials( |
|
|
|
grpc_jwt_credentials_create(json_key.c_str(), lifetime)); |
|
|
|
grpc_jwt_credentials_create(json_key.c_str(), lifetime)); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Builds refresh token credentials.
|
|
|
|
|
|
|
|
std::unique_ptr<Credentials> RefreshTokenCredentials( |
|
|
|
|
|
|
|
const grpc::string& json_refresh_token) { |
|
|
|
|
|
|
|
return WrapCredentials( |
|
|
|
|
|
|
|
grpc_refresh_token_credentials_create(json_refresh_token.c_str())); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// Builds IAM credentials.
|
|
|
|
// Builds IAM credentials.
|
|
|
|
std::unique_ptr<Credentials> IAMCredentials( |
|
|
|
std::unique_ptr<Credentials> IAMCredentials( |
|
|
|
const grpc::string& authorization_token, |
|
|
|
const grpc::string& authorization_token, |
|
|
|