This document describes how to set up a service account for secure
communication.

## Set up your service account for service-to-service communication

This guide shows how to set up a service account for security and
service-to-service communication. While you may have completed some of these
steps in the [Create service
accounts](https://cloud.google.com/iam/docs/service-accounts-create#iam-service-accounts-create-gcloud)
page, this document provides additional instructions for setting up a service
account to access the Navigation Connect API.

### gcloud

Replace <var translate="no">${project_id}</var> with your project ID and
<var translate="no">${service_account_email}</var> with your service
account email.

The following steps use the GCloud SDK:

1. Create a service account which will be used to access the
   Navigation Connect API.

   ```bash
   gcloud --project=${project_id} iam service-accounts create navigationconnect
   ```
2. Give the account the Service Account Token Creator role.

   ```bash
   gcloud projects add-iam-policy-binding ${project_id} \
     --member=serviceAccount:${service_account_email} \
     --role=roles/iam.serviceAccountTokenCreator
   ```
3. Give the account the Navigation Connect administrator role.

   ```bash
   gcloud projects add-iam-policy-binding ${project_id} \
       --member=serviceAccount:${service_account_email} \
       --role=roles/navigationconnect.admin
   ```

For service accounts that only need read access to trips using `GetTrip`, use
the role `roles/navigationconnect.viewer`.