Get a service account

Stay organized with collections Save and categorize content based on your preferences.

Demonstrates retrieving a service account.

Code sample


To learn how to install and use the client library for IAM, see IAM client libraries. For more information, see the IAM C++ API reference documentation.

namespace iam = ::google::cloud::iam;
[](std::string const& name) {
  iam::IAMClient client(iam::MakeIAMConnection());
  auto response = client.GetServiceAccount(name);
  if (!response) throw std::runtime_error(response.status().message());
  std::cout << "ServiceAccount successfully retrieved: "
            << response->DebugString() << "\n";

What's next

To search and filter code samples for other Google Cloud products, see the Google Cloud sample browser.