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
  1. TMC is currently READ ONLY.
    Click here for more info.

Tesla API Token Generator

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

Tags:
  1. HankLloydRight

    HankLloydRight No Roads

    Joined:
    Jan 18, 2014
    Messages:
    12,795
    Location:
    Connecticut
    Yeah, I saw that. I'll look into it, but not sure I have time currently.
    All the tampermonkey code is open-source javascript if anyone else wants to take a crack at it.
     
  2. MrTemple

    MrTemple Member

    Joined:
    Jul 16, 2020
    Messages:
    105
    Location:
    Pacific North Wilderness
  3. luckyj

    luckyj Member

    Joined:
    Dec 8, 2016
    Messages:
    412
    Location:
    Northern Virginia, USA
  4. luckyj

    luckyj Member

    Joined:
    Dec 8, 2016
    Messages:
    412
    Location:
    Northern Virginia, USA
    The PHP script MrTemple mentioned also didn't work, same issue noted by others on that page.
     
  5. luckyj

    luckyj Member

    Joined:
    Dec 8, 2016
    Messages:
    412
    Location:
    Northern Virginia, USA
    Well this morning the Teslascope script worked, nothing changed on my end. Guess there was some maintenance or a problem last night.
     
    • Informative x 1
  6. luckyj

    luckyj Member

    Joined:
    Dec 8, 2016
    Messages:
    412
    Location:
    Northern Virginia, USA
    Hmmm. I got a token from the script but it doesn't seem to be working - getting 401s from API calls. New token seems really long, 870 bytes versus 68 bytes on my previous token.

    Ugh, help! Anyone have a python script that gets a token, and then performs a command that works?
     
  7. Daniellane

    Daniellane Active Member

    Joined:
    Aug 13, 2017
    Messages:
    2,367
    Location:
    Camas, Washington
  8. luckyj

    luckyj Member

    Joined:
    Dec 8, 2016
    Messages:
    412
    Location:
    Northern Virginia, USA
    #108 luckyj, Feb 27, 2021
    Last edited: Feb 27, 2021
    No iOS here, but thanks for the suggestion.

    Sorry if I'm asking dumb questions, but I'm having a hard time figuring the new system out.

    Does this look like the format of current tokens? (it's obfuscated a bit)

    Code:
    eyphbGckOkpSUzk1NkksknR5cCk6kkpXtCkskmtpZCk6km9UaDR1ZXNoM2tlZXptWDB1kn0.eyJpc3fiOipodHRwcbovLtr1dllbdlVbblEb7t9tLt9hdXRofi9tf7IsIfr1bCI6Ifh4dHBbOi8v7XV4aC54bXNs7S5pbt4vbtr1dll7L37bL3RvatVbIiwiaWr4IpoxNpE4NDA7ODE5LCpb73AiOlsib3BlbflkIiwibtbfbllbbV9h7tNlc3fiXSwiblr47SI6e7ptIpoifSIsIfr1bCI6Ifh4dHBbOi8vb3dbbXIt7XBpLnRlctxhbW94b3pbLfNvbS8iLCpbdWIiOipiODNhblE4fi437phlLTQwODAtOl7wN743OTliNpI7fbbxblIiLCpb73AiOlsib3BlbflkIiwibW1haWwiLCpvbfbsaW5lXtrp7tVbc7pdLCphenAiOipvdt5lcfrwaSIsIfrtciI6W7pwdtQiXSwi7XV4ar94aW1lIpoxNpE4NDA7ODE5rX4.lt7EaElel3cwldoNx7DH5tltcqqOXD8EbrQlarbWib7bApKrp3aaPn-At7twK7TrB7ElL4lEx7HrhvOxsprbqSblqrNeBQRH4elVWHDl7n9Aw1v6lhHx4a9RDfTbIo1oIpn1wS_4l96nf_palQlAbpA6Ca_r8dKCbWrSC7tlPbHp9Xd8bcefl77xXapRlt3Rerb53rhaQPrfOAf77d774h3wAbRPW5pDNbfbx98eItLNf7A8b5O7panPbdbXxQ7bbRppl7DRL9wqd4iWbBlxlvRplf7ofiI6Qkspbl7rRNVQSo1b7bl_hV88Db7ENSbkfrdlP4pfw46KIPRdSblklQ
     
  9. luckyj

    luckyj Member

    Joined:
    Dec 8, 2016
    Messages:
    412
    Location:
    Northern Virginia, USA
    After reading Authentication a little more closely, that token above seems to be the JWT token that has to be exchanged per step 4. The teslascope script doesn't seem to do that. The enode-engineering one does, but I'm having trouble running it. So trying to use Postman, but at the moment I'm getting
    {"error": "unsupported SSO app"}. Found a few places that suggest it could be a header issue. Still investigating...
     
  10. lgkahn

    lgkahn Member

    Joined:
    Oct 27, 2018
    Messages:
    24
    Location:
    new england
    if anyone comes up with a script or webpage that actually works let me know the one on teslafi works, but i really want to generate a token with a separate username and password to use in my home automation integration.
     
  11. luckyj

    luckyj Member

    Joined:
    Dec 8, 2016
    Messages:
    412
    Location:
    Northern Virginia, USA
    Okay, I got the script from enode-engineering/tesla-oauth2 to work. Had to add --verbose to the command line otherwise there's a python error. And you have to save to a file with the -f option because the code that is printed to the console is NOT the access code.
     
  12. luckyj

    luckyj Member

    Joined:
    Dec 8, 2016
    Messages:
    412
    Location:
    Northern Virginia, USA
    #112 luckyj, Feb 27, 2021
    Last edited: Feb 27, 2021
    Looks like the code for the enode-engineering script was updated last night after I downloaded it. The --verbose is no longer needed, the issue looks like it was fixed. But -f is still needed.

    Now the selenium python library is required, chromium-browser/chromedriver has to be installed, and libnss3 installed. And for me, sometimes it fails with "unknown error: DevToolsActivePort file doesn't exist", but running a little later works.
     

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