Skip to content

Instantly share code, notes, and snippets.

@jamesmartin
Created January 12, 2021 06:17
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jamesmartin/686a8d861111703e0143c8eee49d2c86 to your computer and use it in GitHub Desktop.
Save jamesmartin/686a8d861111703e0143c8eee49d2c86 to your computer and use it in GitHub Desktop.
Fetches a new OAuth 2.0 token from the Tesla API using the email and password of a Tesla account
#!/bin/sh
# Fetches a new OAuth 2.0 token from the Tesla API using email and password of
# a Tesla account.
CLIENT_ID=81527cff06843c8634fdc09e8ac0abefb46ac849f38fe1e431c2ef2106796384
CLIENT_SECRET=c7257eb71a564034f9419ee651c7d0e5f7aa6bfbd18bafb5c5c033b093bb2fa3
GRANT_TYPE=password
while getopts e:p: option
do
case "${option}"
in
e) EMAIL=${OPTARG};;
p) PASSWORD=${OPTARG};;
esac
done
if [ -z ${PASSWORD+x} ]; then
read -p "Email: " EMAIL
read -sp "Password: " PASSWORD
echo
fi
curl -XPOST https://owner-api.teslamotors.com/oauth/token -d "password=$PASSWORD&email=$EMAIL&client_secret=$CLIENT_SECRET&client_id=$CLIENT_ID&grant_type=$GRANT_TYPE"
@udaykor
Copy link

udaykor commented Aug 14, 2023

Endpoint is now deprecated I think

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment