This guide helps you verify that your Fleet Engine authorization setup is
complete, and that you can create a trial vehicle. This guide uses
[the `gcloud` command line utility](https://cloud.google.com/sdk/gcloud) to test
authorization token signing and vehicle creation.

To complete this process, do the following:

1. Replace the fields below with the data you created as part of the setup:

| Field | Replace with |
|---|---|
| <var class="edit" scope="PROJECT_ID" translate="no">PROJECT_ID</var> | Your Cloud project ID. |
| <var class="edit" scope="SERVICE_ACCOUNT_EMAIL_ADDRESS" translate="no">SERVICE_ACCOUNT_EMAIL_ADDRESS</var> | The email address of a service account you've created with the Admin role. See [Mobility service account roles](https://developers.google.com/maps/documentation/mobility/fleet-engine/essentials/set-up-fleet/service-accounts.md.txt#mobility_service_account_roles) for details. |
| <var class="edit" scope="VEHICLE_ID" translate="no">VEHICLE_ID</var> **OR** <var class="edit" scope="DELIVERY_VEHICLE_ID" translate="no">DELIVERY_VEHICLE_ID</var> | A random ID for the vehicle. The ID can contain a maximum of 64 characters. |

1. Use the `gcloud` utility to log into the Google Cloud account and set the
   active project on your workstation:

   ```bash
   gcloud auth login
   gcloud config set project PROJECT_ID
   ```
2. Create a JSON Web Token (JWT) claim for the vehicle creation:

   ### On-demand trips

   ```
       cat > claim.jwt << EOM
       {
         "iss": "SERVICE_ACCOUNT_EMAIL_ADDRESS",
         "sub": "SERVICE_ACCOUNT_EMAIL_ADDRESS",
         "aud": "https://fleetengine.googleapis.com/",
         "iat": $(date +%s),
         "exp": $((`date +%s` + 3600)),
         "authorization": {
           "vehicleid": "VEHICLE_ID"
         }
       }
       EOM
       
   ```

   ### Scheduled tasks

   ```
       cat > claim.jwt << EOM
       {
         "iss": "SERVICE_ACCOUNT_EMAIL_ADDRESS",
         "sub": "SERVICE_ACCOUNT_EMAIL_ADDRESS",
         "aud": "https://fleetengine.googleapis.com/",
         "iat": $(date +%s),
         "exp": $((`date +%s` + 3600)),
         "authorization": {
           "deliveryvehicleid": "DELIVERY_VEHICLE_ID"
         }
       }
       EOM
       
   ```
3. Use `gcloud` to sign this JWT with the appropriate IAM permissions. :

   ```bash
   gcloud iam service-accounts sign-jwt claim.jwt output.jwt \
     --iam-account=SERVICE_ACCOUNT_EMAIL_ADDRESS
   ```

   The signed JWT is stored in `output.jwt`.

   For details, see [Provide required permissions](https://cloud.google.com/iam/docs/create-short-lived-credentials-direct#permissions-access) and
   [the `gcloud` command line guide](https://cloud.google.com/sdk/gcloud/reference/beta/iam/service-accounts/sign-jwt) in the Google Cloud
   documentation.
4. Use `curl` to create a test vehicle on Fleet Engine:

   ### On-demand trips

   ```
       curl -X POST "https://fleetengine.googleapis.com/v1/providers/PROJECT_ID/vehicles?vehicleId=VEHICLE_ID" \
         -H "Content-type: application/json" \
         -H "Authorization: Bearer $(cat output.jwt)" \
         --data-binary @- << EOM
       {
         "name": "providers/PROJECT_ID/vehicles/VEHICLE_ID"
       }
       EOM
       {
         "vehicleState": "OFFLINE",
         "supportedTripTypes": ["EXCLUSIVE"],
         "maximumCapacity": 4,
         "vehicleType": {"category": "AUTO"},
         "attributes": [{"key": "on_trip", "value": "false"}]
       }
       
   ```

   This command should print the name of the vehicle as output. If you
   see the following text, your setup is successful.

   ```
       {
         "name": "providers/PROJECT_ID/vehicles/VEHICLE_ID"
       }
       
   ```

   ### Scheduled tasks

   ```
       curl -X POST "https://fleetengine.googleapis.com/v1/providers/PROJECT_ID/deliveryVehicles?deliveryVehicleId=DELIVERY_VEHICLE_ID" \
         -H "Content-type: application/json" \
         -H "Authorization: Bearer $(cat output.jwt)" \
         --data-binary @- << EOM
       {
         "name": "providers/PROJECT_ID/deliveryVehicles/DELIVERY_VEHICLE_ID"
       }
       EOM
       
   ```

   This command should print the name of the delivery vehicle as output. If you
   see the following text, your setup is successful.

   ```
       {
         "name": "providers/PROJECT_ID/deliveryVehicles/DELIVERY_VEHICLE_ID"
       }
       
   ```

   > [!NOTE]
   > **Note:** Fleet Engine automatically purges all entities (including vehicles) after 7 days of inactivity, such as updates.

## What's next

- [Troubleshoot common issues](https://developers.google.com/maps/documentation/mobility/fleet-engine/essentials/set-up-fleet/troubleshoot.md.txt)
- [Create and use vehicles](https://developers.google.com/maps/documentation/mobility/fleet-engine/essentials/vehicles.md.txt)