Verify your setup

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, 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.
  1. Use the gcloud utility to log into the Google Cloud account and set the active project on your workstation:

    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:

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

    The signed JWT is stored in output.jwt.

    Refer to the gcloud command line guide for more details.

  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"
        }
        

What's next