GithubHelp home page GithubHelp logo

fredli74 / fetch-tesla-token Goto Github PK

View Code? Open in Web Editor NEW
20.0 8.0 5.0 208 KB

Simple Node.js server for fetching Tesla API tokens

License: MIT License

JavaScript 61.33% HTML 37.27% Dockerfile 1.41%
tesla tesla-api

fetch-tesla-token's Introduction

fetch-tesla-token

Simple node.js server for fetching Tesla tokens

Why a server?

The Tesla APIs are only intended for the official Tesla App, therefore there are deliberate limitations that prevent the ease of use for third party solutions. One of those limitations is that CORS prevents any other domain than tesla.com to access the API directly from a browser. Calling the API from a node.js server works fine.

How does it work?

Tesla is constantly seeking ways to make their sign in more secure, and when they do, third party solutions tends to break. I finally came to the conclusion that the best way forward is to use the official sign in flow as much as possible. An added benefit to this decision is that users email, password, and MFA codes are never entered or proxied through this server, they are only used directly on the official secure Tesla page. The drawback is that it requires an additional manual step by the user at the end.

  1. The server generates a random session id and creates a unique sign in link to tesla.com

  2. The user visit the link and sign in

  3. Once signed in, the user is redirected to a page on tesla.com that does not exist. This is how Tesla uses it internally and it is intentional.

  1. The user copies the full url https://auth.tesla.com/void/callback?code=... and provides it to this server.

  2. The server decode the url and then call the Tesla Authentication servers to generate bearer and owner-api tokens.

Is it safe?

Yes. But don't just trust my word, verify!

  • It's open source
  • Download and run locally
  • Server only using node.js standard library (no node_modules needed)
  • Client is single html file (no third-party browser libraries)
  • Small code base, review it all in minutes

How do I run it locally?

git clone https://github.com/fredli74/fetch-tesla-token.git
cd fetch-tesla-token/
npm run start

Or use the simple command-line version with

npm run cli

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.