TMC is an independent, primarily volunteer organization that relies on ad revenue to cover its operating costs. Please consider whitelisting TMC on your ad blocker and becoming a Supporting Member. For more info: Support TMC

Tesla API Token Generator

Discussion in 'Model S' started by MarcusMaximus, Jan 6, 2017.

Tags:
  1. coreyward

    coreyward New Member

    Joined:
    Oct 7, 2017
    Messages:
    1
    Location:
    Austin, TX
    For those of you that were looking for a way to do this on the web without installing anything or using the command line, here you go!

    TokensForTeslas
     
    • Helpful x 2
    • Like x 2
  2. tllt

    tllt Member

    Joined:
    Sep 4, 2017
    Messages:
    115
    Location:
    California
    As always, be cautious about entering your Tesla credentials into someone else's site. There is always the possibility of that site saving your creds. Not a knock on your site corey, but just a general warning.

    Also, it would be better for your python script if you didn't enter the password as an argument in the command line as that is shown on the screen and if in *nix systems, is logged in a cmd line history. A better method would be to use getpass to have it prompt for the password and not have it visible on the screen.

    Example:

    import getpass
    passwd = getpass.getpass()
     
    • Like x 1
  3. aseabridge

    aseabridge New Member

    Joined:
    Mar 27, 2018
    Messages:
    1
    Location:
    Manchester
    Being a developer myself I too am always concerned about security with using a Site created by anyone else. Corey looks legit and good at what he does but even so I decided to use Postman to do this instead as I didn't want to have to write and code or install NPM packages or Python.

    Step 1) Download Postman App to your PC of Mac from here: Download Postman
    Step 2) Click import and enter this link: https://www.getpostman.com/collections/2fc311bd4ce4f5c52f6d
    Step 3) Fill in your username and password
    [​IMG]
    Step 4) Click 'Send', Postman will make a request to the API and return a token
    Step 5) Copy the token from the API response and use it

    You should see there is no special code here and nothing custom it is just a pre-configured Postman request to help with getting a new token.

    This is completely safe as you are just making a direct call to the Tesla API from your PC or Mac to get a token and are not using any 3rd party code or sites. Just be careful where you store/save the token.

    Hope this helps.
     
    • Like x 5
    • Helpful x 3
    • Informative x 3
  4. problem??

    problem?? New Member

    Joined:
    May 10, 2018
    Messages:
    2
    Location:
    US
     
  5. problem??

    problem?? New Member

    Joined:
    May 10, 2018
    Messages:
    2
    Location:
    US
    Thanks It worked perfectly!
     
  6. Cooker

    Cooker Member

    Joined:
    Sep 30, 2017
    Messages:
    44
    Location:
    Birmingham, UK
    Hi there. Does anybody know of an iOS app that requires token only and doesn’t require login creds. Unhappy to share latter, have token.
     
  7. HankLloydRight

    HankLloydRight No Roads

    Joined:
    Jan 18, 2014
    Messages:
    10,795
    Location:
    Connecticut
    #47 HankLloydRight, Jun 22, 2018
    Last edited: Jun 22, 2018
    Well, here's another solution that doesn't run on anyone's server, so no uploading your credentials or security concerns.

    It doesn't require Python, Ruby, CURL, PHP, Postman, or using a command line in OSX or Linux.

    It only requires the well-known browser plugin Tampermonkey for Chrome or Firefox (see: Tampermonkey) , and my one-line script available here:

    About | Telsa API Token Generator | Userscripts | OpenUserJS

    Once you install Tampermonkey, and install my script above (one click), just go to this Tesla API URL in your browser:

    https://owner-api.teslamotors.com/oauth/token

    The script will add a form to enter your credentials, and from the same Teslamotors.com domain, submit your credentials to the API and return the JSON with your token.
     
    • Like x 4
  8. RyanDe

    RyanDe Member

    Joined:
    Aug 24, 2016
    Messages:
    184
    Location:
    Massachusetts
    How do you get energy information or is this information derived?
     
  9. Naonak

    Naonak Member

    Joined:
    Dec 22, 2015
    Messages:
    738
    Location:
    Kansas
    You don't. Tesla stopped providing it. You're SOL.
     
  10. hammster

    hammster New Member

    Joined:
    Aug 1, 2018
    Messages:
    1
    Location:
    32216
    Another way without using Tampermonkey or third part websites:


    1. Install the Apiary chrome web extension here:
    https://chrome.google.com/.../cboekbiaoabkhgjdclenjpipcla...

    (This extension lets you send requests to Tesla straight from your Chrome browser instead of going through some unknown third party!)

    2. Go to https://timdorr.docs.apiary.io/...

    (You should see "Console calls are private now" if you completed step #1)

    3. Click "Add a new query parameter" and for "New item" type "grant_type" (without the quotes of course), hit TAB and "null" should be highlighted. Type "password"'.

    grant_type is the name of the query parameter, while password is the value of the query parameter.

    4. Repeat Step 3, but with each of these:
    Name: client_id, value: 81527cff06843c8634fdc09e8ac0abefb46ac849f38fe1e431c2ef2106796384

    Name: client_secret, value: c7257eb71a564034f9419ee651c7d0e5f7aa6bfbd18bafb5c5c033b093bb2fa3

    Name: email, value: [email protected]
    Name: password, value: YOUR TESLA password

    5. Then click "Call Resource"

    6. You should then see a "Response" section appear. Scroll down and look for:
    "access_token": "abc123",

    Copy all the text inside the second set of quotation marks (in the example that would be abc123)

    That is your access token. You can use that to start your Teslafi account without giving them your login information.

    A picture is worth a thousand words:
     

    Attached Files:

    • Helpful x 3
    • Informative x 1
  11. syoo47

    syoo47 Member

    Joined:
    Aug 16, 2017
    Messages:
    6
    Location:
    Los Angeles
    Is there a similar method for listing and revoking tokens?

     
  12. melds

    melds New Member

    Joined:
    Aug 13, 2018
    Messages:
    1
    Location:
    CA
    The API seems to accept https://owner-api.teslamotors.com/oauth/revoke, but that didn't seem to delete it ({"token": (access_token), "token_type_hint"="access_token"}). The default life is 45 days but can be extended with the refresh token.
     
  13. Daniellane

    Daniellane Active Member

    Joined:
    Aug 13, 2017
    Messages:
    1,389
    Location:
    Camas, Washington
  14. HankLloydRight

    HankLloydRight No Roads

    Joined:
    Jan 18, 2014
    Messages:
    10,795
    Location:
    Connecticut
    Still has the same problem that you don't know what the app is actually doing with your Tesla login credentials.
     
  15. HankLloydRight

    HankLloydRight No Roads

    Joined:
    Jan 18, 2014
    Messages:
    10,795
    Location:
    Connecticut
    I'm pretty sure if you change your Tesla Account password, it instantly invalidates all tokens.
     
    • Like x 1
  16. Daniellane

    Daniellane Active Member

    Joined:
    Aug 13, 2017
    Messages:
    1,389
    Location:
    Camas, Washington
    @spudnik187 is the App developer. Perhaps he’ll shed some light here.
     
  17. Fellsteruk

    Fellsteruk Member

    Joined:
    Feb 24, 2018
    Messages:
    630
    Location:
    North West, UK
    Tried post man and Apiary neither seem to work 3(
     
  18. Randy Spencer

    Randy Spencer Active Member

    Joined:
    Mar 31, 2016
    Messages:
    1,106
    Location:
    Alameda, CA
    Use the curl script, works great on my Mac in a Terminal window, and I don't have to worry about what the code does, it's all in the single command line. Pasted the updated token to EV-FW.com and it immediately got my newest update and listed it. Sweet

    -Randy
     
  19. Tantamount

    Tantamount New Member

    Joined:
    Jul 10, 2018
    Messages:
    4
    Location:
    Bay Area, CA
    Just heads up -- I was writing my own script to do this and after repeated 401 replies from Tesla eventually discovered that these don't work.

    These do:

    'client_id':'e4a9949fcfa04068f59abb5a658f2bac0a3428e4652315490b659d5ab3f35a9e',
    'client_secret':'c75f14bbadc8bee3a7594412c31416f8300256d7668ea7e6e7f06727bfb9d220',
     
    • Informative x 1
  20. Mobsidian

    Mobsidian Member

    Joined:
    Oct 31, 2017
    Messages:
    112
    Location:
    Ajax, ON
    When I import that I don't see the entries populated like you have in the screenshot. What am I missing here?
     

Share This Page

  • About Us

    Formed in 2006, Tesla Motors Club (TMC) was the first independent online Tesla community. Today it remains the largest and most dynamic community of Tesla enthusiasts. Learn more.
  • Do you value your experience at TMC? Consider becoming a Supporting Member of Tesla Motors Club. As a thank you for your contribution, you'll get nearly no ads in the Community and Groups sections. Additional perks are available depending on the level of contribution. Please visit the Account Upgrades page for more details.


    SUPPORT TMC