#!/bin/bash #Set un and pw to your email and pw you use to log in to https://www.myfordmobile.com/content/mfm/app/site/login.html UN='elitehaxor@aol.com' PW='password11!one' #Your vin is needed in case there's more than one vehicle on your account. All 17 characters, All caps, no spaces. VIN='7FA7P7SU7XX777777' #A Bearer ID is needed to prove you're worthy to use the interface. It's more or less one unchanging password the whole world shares. You shouldn't need to change it Bearer='b7bdf3f01761660c87a6b3b21afb898a' #Here's how to find the Bearer in case it changes some day: #Bearer="$( curl 'https://www.myfordmobile.com/etc/clientlibs/mfm-wcm/javascript/desktop.436.min.js' | grep Bearer | sed 's/.*Bearer\ //;s/\".*//' ) #Yes. that url looks sus. If it doesn't work, Check for desktop.somenumbers, in the network tab in firefox' F12 analyzer mode #Okay. First interaction you need to log in and get a AuthToken AuthToken="$( curl -s --header 'Authorization: Bearer '"${Bearer}" --header "Content-Type: application/json" --request POST --data '{"PARAMS":{"emailaddress":"'"${UN}"'","password":"'"${PW}"'","persistent":"0","appVersion":"web-2.0.51","apiLevel":"2"}}' https://www.myfordmobile.com/services/webLoginPS | jq -r '.response.authToken' )" #AuthToken should look like a windows GUID 1077524b-20a5-420d-886e-b7b691dfac01 #Second interaction, use the AuthToken (Calling it a SESSIONID now) to get the data on all vehicles. AllVehiclesResponse="$( curl -s --header "Content-Type: application/json" --request POST --data '{"PARAMS":{"SESSIONID":"'"${AuthToken}"'","apiLevel":"2","ck":"1619917185457"}}' https://www.myfordmobile.com/services/webGetAllVehiclesPS )" #pull the electric Distance To Empty value KMsRemaining="$( jq -r '.getAllVehiclesResponse.vehicle[] | select(.vin=="'"${VIN}"'").ELECTRICDTE' <<< "${AllVehiclesResponse}" )" #Convert it to patriotic units MisRemaining="$( bc <<<"scale=3; 0.621371 * ${KMsRemaining}" )" echo "${VIN} can drive ${MisRemaining} miles on battery."