/*!
@page bigtable-samples-grpc-credentials Example: Use Cloud Bigtable C++ client with various gRPC credential classes

# Use gRPC Credential Classes with Cloud Bigtable C++ client

## Before you begin

### Set the Environment Variable

There are many ways to authenticate with Google Cloud Platform, here we use
the `GOOGLE_APPLICATION_CREDENTIALS` environment variable to setup
authentication based on a key file:

`export GOOGLE_APPLICATION_CREDENTIALS="[PATH]"`

where [PATH] is file path for JSON file that contains either user account or Service account key. Please refer [this link][info-google-authentication] for more details on Google Authentication.

## Use Access Token Credentials

Acquire Access Token

Use [gcloud][print-access-token] to acquire an Access Token

The following code shows how to use access token to connect to an Admin API endpoint.

@snippet bigtable_grpc_credentials.cc test access token

## Use Refresh Token Credentials

Sample code to connect to an Admin API endpoint

```
#include "google/cloud/bigtable/admin/bigtable_instance_admin_client.h"
#include "google/cloud/project.h"

int main(int argc, char* argv[]) try {
  namespace cbta = ::google::cloud::bigtable_admin;
  namespace gc = ::google::cloud;
  std::string const project_id = argv[1];
  grpc::string refresh_token = R"""({
      "client_id": "XXXXXX.apps.googleusercontent.com",
      "client_secret": "<actual secret here>",
      "refresh_token": "<actual token value here>",
      "type": "authorized_user"
  })""";
  auto call_credentials = grpc::GoogleRefreshTokenCredentials(refresh_token);
  auto channel_credentials =
      grpc::SslCredentials(grpc::SslCredentialsOptions());
  auto credentials =
      grpc::CompositeChannelCredentials(channel_credentials, call_credentials);
  auto client = cbta::BigtableInstanceAdminClient(
      cbta::MakeBigtableInstanceAdminConnection(
          gc::Options{}.set<gc::GrpcCredentialOption>(credentials)));
  auto instances = client.ListInstances(gc::Project(project_id).FullName()));
  return 0;
} catch (std::exception const& ex) {
  std::cerr << "Standard C++ exception raised: " << ex.what() << std::endl;
  return 1;
}
```

## Use JWT Access Token Credentials

The following code shows how to use a JWT access token to connect to an Admin API endpoint.

@snippet bigtable_grpc_credentials.cc test jwt access token

## Use Google Compute Engine Credentials

The following code shows how to use a GCE credentials to connect to an Admin API endpoint.

## Use of IAM Credentials

### Check IAM Policy

@snippet table_admin_iam_policy_snippets.cc get iam policy

### Set IAM Policy

@snippet table_admin_iam_policy_snippets.cc set iam policy

### Check IAM Permissions

@snippet table_admin_iam_policy_snippets.cc test iam permissions

[info-google-authentication]: https://cloud.google.com/docs/authentication/getting-started
[info-root-certificates]: https://github.com/googleapis/google-cloud-cpp/tree/main/google/cloud/bigtable/examples#configure-grpc-root-certificates
[print-access-token]: https://cloud.google.com/sdk/gcloud/reference/beta/auth/application-default/print-access-token

*/
