--- title: ALTS authentication linkTitle: ALTS description: >- An overview of gRPC authentication in C++ using Application Layer Transport Security (ALTS). weight: 75 spelling: cSpell:ignore Authz creds grpcpp code: client_credentials: | ```cpp #include #include using grpc::experimental::AltsCredentials; using grpc::experimental::AltsCredentialsOptions; auto creds = AltsCredentials(AltsCredentialsOptions()); std::shared_ptr channel = CreateChannel(server_address, creds); ``` server_credentials: | ```cpp #include #include #include using grpc::experimental::AltsServerCredentials; using grpc::experimental::AltsServerCredentialsOptions; grpc::ServerBuilder builder; builder.RegisterService(&service); auto creds = AltsServerCredentials(AltsServerCredentialsOptions()); builder.AddListeningPort("[::]:", creds); std::unique_ptr server(builder.BuildAndStart()); ``` server_authorization: | ```cpp #include #include using grpc::experimental::AltsCredentials; using grpc::experimental::AltsCredentialsOptions; AltsCredentialsOptions opts; opts.target_service_accounts.push_back("expected_server_service_account1"); opts.target_service_accounts.push_back("expected_server_service_account2"); auto creds = AltsCredentials(opts); std::shared_ptr channel = CreateChannel(server_address, creds); ``` client_authorization: | ```cpp #include #include grpc::ServerContext* context; grpc::Status status = experimental::AltsClientAuthzCheck( context->auth_context(), {"foo@iam.gserviceaccount.com"}); ``` --- {{% docs/auth_alts %}}