diff options
Diffstat (limited to 'src/cpp/client')
-rw-r--r-- | src/cpp/client/secure_credentials.cc | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/src/cpp/client/secure_credentials.cc b/src/cpp/client/secure_credentials.cc index 47f645c1b6..795d7731c9 100644 --- a/src/cpp/client/secure_credentials.cc +++ b/src/cpp/client/secure_credentials.cc @@ -104,6 +104,15 @@ std::unique_ptr<Credentials> ServiceAccountCredentials( json_key.c_str(), scope.c_str(), lifetime)); } +// Builds JWT credentials. +std::unique_ptr<Credentials> JWTCredentials( + const grpc::string &json_key, std::chrono::seconds token_lifetime) { + gpr_timespec lifetime = gpr_time_from_seconds( + token_lifetime.count() > 0 ? token_lifetime.count() : 0); + return WrapCredentials( + grpc_jwt_credentials_create(json_key.c_str(), lifetime)); +} + // Builds IAM credentials. std::unique_ptr<Credentials> IAMCredentials( const grpc::string& authorization_token, |