teslamotors / vehicle-command

Apache License 2.0
445 stars 102 forks source link

Using the proxy: "public key has not been paired with the vehicle" #30

Closed rawmean closed 1 year ago

rawmean commented 1 year ago

I am trying to use the proxy (from VehicleCommands repo) to send commands to the car.

I have made sure that the car has received the public key. I also made sure that the key associated with my domain shows up in the car under “Locks” menu.

Then I send a flash_lights command using the following command:

curl -i  \
    --header 'Content-Type: application/json' \
    --header "Authorization: Bearer $TESLA_AUTH_TOKEN" \
    --data '{}' \
    "https://my_proxy/api/1/vehicles/$VIN/command/flash_lights”

I get http 500 response with the following body:

{"response":null,"error":"vehicle rejected request: your public key has not been paired with the vehicle","error_description":""}

The following is from the proxy after issuing the “flash_lights” command.

Question: Is there something else that I need to do to make the car respond to the command?

Getting information from the car through the proxy works (eg, vehicle_data), but requires the car to be awake (unlike the Fleet API which returns cached data if the car is asleep)

My car is running 2023.27.7 firmware. I assume this version does support responding to singed messages. Can you please confirm?

2023-11-04T21:12:28Z [info ] Received POST request for /api/1/vehicles/my_vin/command/flash_lights
2023-11-04T21:12:28Z [debug] Executing flash_lights on my_vin
2023-11-04T21:12:28Z [info ] Starting dispatcher service...
2023-11-04T21:12:28Z [info ] Requesting session info from DOMAIN_INFOTAINMENT
2023-11-04T21:12:28Z [debug] Sending request to https://fleet-api.prd.na.vn.cloud.tesla.com/api/1/vehicles/my_vin/signed_command: {"routable_message":"MgIIAzoSEhAKeZEi+J+W9qZhXuGnxAVymgMQVc+E3tlMAyyonuiOeOfB63JDCkEELzp+ThrD9y07EO7W9WAjywmhRz1XAdhOw/ZONzrPkyXnBxBVI+eocdcT/2OB5jdHKJbWcWX+nOThRofNemg=="}
2023-11-04T21:12:28Z [info ] Requesting session info from DOMAIN_VEHICLE_SECURITY
2023-11-04T21:12:28Z [debug] Sending request to https://fleet-api.prd.na.vn.cloud.tesla.com/api/1/vehicles/my_vin/signed_command: {"routable_message":"MgIIAjoSEhA27JCxkmgbopzQHtbSqxLMmgMQE+bEwiNGf2YFQU/NCybXFXJDCkEELzp+ThrD9y07EO7W9WAjywmhRz1XAdhOw/ZONzrPkyXnBxBVI+eocdcTxf8/2OdHKJbWcWX+nOThRofNemg=="}
2023-11-04T21:12:28Z [debug] Server returned 200: OK: {"response":"MhISEAp5kSL4n5b2pmFe4afEBXI6AggDYgQIAhADkgMQVc+E3tlMAyyonuiOeOfB6w=="}
2023-11-04T21:12:28Z [error] Returning error Internal Server Error
2023-11-04T21:12:28Z [debug] [13e6c4c223467f6605414fcd0b26d715] Retrying transmission after error: Post "https://fleet-api.prd.na.vn.cloud.tesla.com/api/1/vehicles/my_vin/signed_command": context canceled
rawmean commented 1 year ago

I found the problem. My private and public keys did not match and that cause the problem.