Skip to content

RealCarvedArt/tesla-oauth2

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

72 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Generate V3 Refresh Token for API Authentication using Python

Tesla OAuth Token Generation

A script to interact with the recent OAuth2 changes from Tesla and the new /oauth2/ endpoint.

PREREQUISITES:​

Code:

requests==2.24.0
selenium==3.141.0

STEPS:​

  1. Download the prerequisites
  2. Create a project folder to store your files; e.g., “C:\Users\Username\Desktop\TeslaTokens”
  3. Place: ChromeDriver, auth.tokens.py, and requirements.txt in “C:\Users\Username\Desktop\TeslaTokens”
  4. Install Python FOR ALL USERS and add to PATH (If you need help installing Python there are plenty of great videos out there explaining the process for each system)
  5. Launch a command window/terminal (e.g., PowerShell, Command Prompt, Terminal, etc.)
  6. Type:
Code:

CD /d C:\Users\Username\Desktop\TeslaTokens
  • Press: ENTER
  • Type:
Code:

pip install -r requirements.txt
  • Press: ENTER

  • At this point everything should be installed, configured and ready to go Then enter one of the below strings at the command prompt and hit ENTER:

  • If your Tesla account has MFA enabled:

Code:

python3 ./TeslaTokenV3.py -u 'email' -p 'password' -c 'passcode'
  • If your Tesla account does not have MFA enabled:
Code:

python3 ./TeslaTokenV3.py -u 'email' -p 'password'

-u = Tesla account email

-p = Tesla account password

-c = Passcode generated by your authenticator app

  • MFA example:
Code:

python3 ./TeslaTokenV3.py -u myTeslaEmail@someDomain.com -p someSuperSecurePassword -c 123456
  • Non-MFA example:
Code:

python3 ./TeslaTokenV3.py -u myTeslaEmail@someDomain.com -p someSuperSecurePassword

TIPS:​

If python3 does not work try using just python To check your Python install you can type:

Code:

python --version
>python3 ./TeslaTokenV3.py -h
usage: TeslaTokenV3.py [-h] -u EMAIL -p PASSWORD [-v] [-c CODE]

optional arguments:
  -h, --help            show this help message and exit
  -u EMAIL, --email EMAIL
                        • Tesla account email
  -p PASSWORD, --password PASSWORD
                        • Tesla account password
  -v, --verbose         • Verbose output
  -c CODE, --code CODE  • Passcode generated by your authenticator app

Troubleshooting

If you are looking for documentation we suggest you check out https://github.com/timdorr/tesla-api

About

General description about how Tesla does 2FA and how to detect if a user has 2FA enabled

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages

  • Python 60.7%
  • Ruby 39.3%