Welcome to Tesla Motors Club
Discuss Tesla's Model S, Model 3, Model X, Model Y, Cybertruck, Roadster and More.
Register

Tesla API Token Generator

This site may earn commission on affiliate links.
Can anyone that is familiar with Python 3.6 provide some instruction how to run the Teslatoken.py script that was posted in this thread? Perhaps the OP can jump in? I realize that there are other web based tools to do this instead of software like Python but using those third party websites brings up other security concerns.
 
FYI love postman. It has a converter to change to ruby, python, etc its https requests to about a dozen different languages. Been using that tool for years to create bash / curl and use in workflows for some low level automation. Tokens are nice as you can share them with others and depending on access they will not ever have your username / Password. Unless of course the token grants that in the host system for instance.


Sent from my iPhone
 
  • Helpful
Reactions: TaoJones
Here you go, just replace <USERNAME> with your username for Tesla owner login and same for <PASSWORD>

curl -X POST -H "Cache-Control: no-cache" -H "Content-Type: multipart/form-data; boundary=----WebKitFormBoundary7MA4YWxkTrZu0gW" -F "grant_type=password" -F "client_id=81527cff06843c8634fdc09e8ac0abefb46ac849f38fe1e431c2ef2106796384" -F "client_secret=c7257eb71a564034f9419ee651c7d0e5f7aa6bfbd18bafb5c5c033b093bb2fa3" -F "email=<USERNAME>" -F "password=<PASSWORD>" "https://owner-api.teslamotors.com/oauth/token"
 
Here you go, just replace <USERNAME> with your username for Tesla owner login and same for <PASSWORD>

curl -X POST -H "Cache-Control: no-cache" -H "Content-Type: multipart/form-data; boundary=----WebKitFormBoundary7MA4YWxkTrZu0gW" -F "grant_type=password" -F "client_id=81527cff06843c8634fdc09e8ac0abefb46ac849f38fe1e431c2ef2106796384" -F "client_secret=c7257eb71a564034f9419ee651c7d0e5f7aa6bfbd18bafb5c5c033b093bb2fa3" -F "email=<USERNAME>" -F "password=<PASSWORD>" "https://owner-api.teslamotors.com/oauth/token"

@BigD0g thanks for the code. However when I try to execute in mac Terminal with a bogus username and password to test, I get:

curl -X POST -H "Cache-Control: no-cache" -H "Content-Type: multipart/form-data; boundary=----WebKitFormBoundary7MA4YWxkTrZu0gW" -F "grant_type=password" -F "client_id=81527cff06843c8634fdc09e8ac0abefb46ac849f38fe1e431c2ef2106796384" -F "client_secret=c7257eb71a564034f9419ee651c7d0e5f7aa6bfbd18bafb5c5c033b093bb2fa3" -F "[email protected]” -F "password=1234password” "https://owner-api.teslamotors.com/oauth/token"

{"response":"{\"message\"=>\"object_reference_not_set_to_an_instance_of_an_object.\",_\"stacktrace\"=>\"___at_myteslawebservice.controllers.authenticationcontroller.<authenticate>d__1.movenext"}

Any other tips you can give to someone new to this?
 
@BigD0g thanks for the code. However when I try to execute in mac Terminal with a bogus username and password to test, I get:

curl -X POST -H "Cache-Control: no-cache" -H "Content-Type: multipart/form-data; boundary=----WebKitFormBoundary7MA4YWxkTrZu0gW" -F "grant_type=password" -F "client_id=81527cff06843c8634fdc09e8ac0abefb46ac849f38fe1e431c2ef2106796384" -F "client_secret=c7257eb71a564034f9419ee651c7d0e5f7aa6bfbd18bafb5c5c033b093bb2fa3" -F "[email protected]” -F "password=1234password” "https://owner-api.teslamotors.com/oauth/token"

{"response":"{\"message\"=>\"object_reference_not_set_to_an_instance_of_an_object.\",_\"stacktrace\"=>\"___at_myteslawebservice.controllers.authenticationcontroller.<authenticate>d__1.movenext"}

Any other tips you can give to someone new to this?

It will only work with a valid username / password on a valid tesla owner account.
 
Ok it just seems weird bc the error says " object_reference_not_set_to_an_instance_of_an_object " not "invalid username/password

I suspect that is Tesla playing games to prevent people discovering someone's username, and then being able to try to figure out their pwd. From what I can tell Tesla doesn't lock your account after 3 attempts, so if you can figure out the username, you can just go hog wild trying to figure out the password.
 
Can anyone that is familiar with Python 3.6 provide some instruction how to run the Teslatoken.py script that was posted in this thread? Perhaps the OP can jump in? I realize that there are other web based tools to do this instead of software like Python but using those third party websites brings up other security concerns.

python teslatoken.py -e <mytesla email> -p <mytesla password>
 
You can run a simple curl command in the Terminal as follows. Just update the email and password value.

Code:
curl -X POST -H "Cache-Control: no-cache" -H "Content-Type: multipart/form-data; boundary=----WebKitFormBoundary7MA4YWxkTrZu0gW" -F "grant_type=password" -F "client_id=81527cff06843c8634fdc09e8ac0abefb46ac849f38fe1e431c2ef2106796384" -F "client_secret=c7257eb71a564034f9419ee651c7d0e5f7aa6bfbd18bafb5c5c033b093bb2fa3" -F "email=USER_YOUR_EMAIL" -F "password=USER_YOUR_PASSWORD" "https://owner-api.teslamotors.com/oauth/token"
Thank you this one worked perfectly for me :).
 
  • Like
  • Helpful
Reactions: CaliMS and t3slaMS
You can run a simple curl command in the Terminal as follows. Just update the email and password value.

Code:
curl -X POST -H "Cache-Control: no-cache" -H "Content-Type: multipart/form-data; boundary=----WebKitFormBoundary7MA4YWxkTrZu0gW" -F "grant_type=password" -F "client_id=81527cff06843c8634fdc09e8ac0abefb46ac849f38fe1e431c2ef2106796384" -F "client_secret=c7257eb71a564034f9419ee651c7d0e5f7aa6bfbd18bafb5c5c033b093bb2fa3" -F "email=USER_YOUR_EMAIL" -F "password=USER_YOUR_PASSWORD" "https://owner-api.teslamotors.com/oauth/token"
Thanks! This was the easiest method to me :)
 
  • Disagree
  • Like
Reactions: Naonak and t3slaMS