AI-generated Key Takeaways
- 
          This guide provides instructions to verify your Fleet Engine authorization and create a trial vehicle using the gcloudcommand line utility.
- 
          You will need your Cloud project ID, service account email address, and a unique vehicle ID to complete the verification process. 
- 
          The process involves generating and signing a JWT, then using it to create a test vehicle via a curlcommand.
- 
          Successful setup is indicated by the output displaying the name of the created vehicle (e.g., "providers/PROJECT_ID/vehicles/VEHICLE_ID"). 
- 
          Fleet Engine automatically purges inactive vehicles after 7 days, eliminating the need for manual deletion. 
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 to test
authorization token signing and vehicle creation.
To complete this process, do the following:
- Replace the fields below with the data you created as part of the setup:
| Field | Replace with | 
|---|---|
| PROJECT_ID | Your Cloud project ID. | 
| SERVICE_ACCOUNT_EMAIL_ADDRESS | The email address of a service account you've created with the Admin role. See Mobility service account roles for details. | 
| VEHICLE_ID OR DELIVERY_VEHICLE_ID | A random ID for the vehicle. The ID can contain a maximum of 64 characters. | 
- Use the - gcloudutility to log into the Google Cloud account and set the active project on your workstation:- gcloud auth login gcloud config set project PROJECT_ID
- 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
- Use - gcloudto sign this JWT with the appropriate IAM permissions. :- 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 and the - gcloudcommand line guide in the Google Cloud documentation.
- Use - curlto 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" }