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
Start a Discussionhttps://teslamotorsclub.com/tmc/tags/

Tesla login-token generator

Discussion in 'Model S: User Interface' started by VerityZooms, Jul 15, 2017.

  1. VerityZooms

    VerityZooms Member

    Joined:
    Apr 19, 2016
    Messages:
    131
    Location:
    Chicago, IL
    Hey, thought I'd throw this out there real quick: if you're using something like TeslaLog or the My Tesla Alexa-skill, and need an authentication token, I've thrown together a little self-installing tool to generate them quickly. (It doesn't store them anywhere, or contact any servers other than Tesla's — so no giving out your Tesla password to random websites, which is A Good Thing™.)

    If you're a developer like myself, and already have recent npm, you can just use the new npx tool to run this without any installation:
    Code:
    npx generate-tesla-token
    If you have no idea what any of that means, you can open the Terminal application on your Mac, and type these two lines:
    Code:
    npm install -g generate-tesla-token
    generate-tesla-token
    [​IMG]

    (And no, that isn't a working login token in the screenshot. ;))
     
    • Helpful x 2
    • Like x 1
  2. DOCAL

    DOCAL Member

    Joined:
    May 5, 2016
    Messages:
    167
    Location:
    San Jose, CA
    Fun, spoilt :(
     
  3. HankLloydRight

    HankLloydRight Fluxing

    Joined:
    Jan 18, 2014
    Messages:
    8,141
    Location:
    Connecticut
    Nice job.

    Since a lot of people are installing VisibleTesla just to get their list of option codes (and new drive unit code), maybe when you get the token, also grab their options list and optionally display it?
     
  4. dwploc

    dwploc Member

    Joined:
    Jun 28, 2017
    Messages:
    11
    Location:
    Atascocita, Tx
    Tried but err
    (xenial)[email protected]:~/aumc-test$ npx generate-tesla-token
    npx: installed 161 in 14.003s
    Unexpected token function
     
  5. kirkbauer

    kirkbauer Member

    Joined:
    May 31, 2015
    Messages:
    543
    Location:
    Atlanta, GA
    I'm also getting "Unexpected token function"
     
  6. GaryREM

    GaryREM Member

    Joined:
    Jul 16, 2013
    Messages:
    447
    Location:
    Fairfax, VA
    You need to update nodejs to latest. Using v8 of nodejs will work.
     
  7. dwploc

    dwploc Member

    Joined:
    Jun 28, 2017
    Messages:
    11
    Location:
    Atascocita, Tx
    Thanks, I had updated to npm v5.0.3 and node v8.1.4 Now it works great.
     
  8. VerityZooms

    VerityZooms Member

    Joined:
    Apr 19, 2016
    Messages:
    131
    Location:
    Chicago, IL
    Yeah, I'm a lazy buttface, and just knocked this together on a whim — didn't bother testing in older versions. I'm sure I used some ES2016-ism or something by accident.

    I'm happy to accept any pull-request — don't even have to make it pretty; just click the link and fix whichever line's erroring:

    Build software better, together
     
  9. VerityZooms

    VerityZooms Member

    Joined:
    Apr 19, 2016
    Messages:
    131
    Location:
    Chicago, IL
    Sounds out-of-scope, tbh. That said, a generalized npm install -g tesla tool, based on TeslaJS but with a consistent CLI and configstore token-caching, would probably be a well-received project … and given that TeslaJS has done all the hard work, wouldn't be at all difficult to throw together, if you wanted to! <3
     

Share This Page