A "proof-of-concept" script on how to interact with the recent OAuth2 changes from Tesla and the new /oauth2/
endpoint. It was open sources so we could let other people in the community better understand the flow of how secrets were passed around in a token exchange.
- Make sure you have Python 3 installed
- Make sure you have chromedrier installed
pip install -r requirements.txt
- Run the script while passing in email and password along with a token file (not required)
- If account has MFA enabled you need to pass
--passcode UNUSED_PASSCODE
(passcode generated by your authenticator app) or--backup_passcode PASSCODE
(one of your unused backup passcodes) - Tesla supports up to 2 authenticator devices. By default script uses 1st device. You can pass
--device 2
to use 2nd device.
bc@anton-mbp ~/H/p/e/tesla-oauth2> python tesla.py -h
usage: tesla.py [-h] -e EMAIL -p PASSWORD [-f FILE] [--verbose]
[--device {1,2}]
[--passcode PASSCODE | --backup_passcode BACKUP_PASSCODE]
optional arguments:
-h, --help show this help message and exit
-e EMAIL, --email EMAIL
Tesla account email
-p PASSWORD, --password PASSWORD
Tesla account password
-f FILE, --file FILE Filename to save tokens
--verbose Be verbose
--device {1,2} 2FA device to use
--passcode PASSCODE Passcode generated by your authenticator app
--backup_passcode BACKUP_PASSCODE
Unused backup passcode
If you are looking for documentation we suggest you check out https://github.com/timdorr/tesla-api