Giter Site home page Giter Site logo

teslaauth's Introduction

TeslaAuth library for C# / .NET Core

Helper library to authenticate to Tesla Owner API.

Includes support for MFA.

This code is heavily based on Christian P's work in the TeslaLogger tool. My changes were largely to make it reusable.

Thanks also to Tim Dorr for his work in documenting the new API, and Ramon Smits for his contributions to this library.

Install

The package is available via NuGet with the package name TeslaAuth.

Install-Package TeslaAuth

Example

Since Tesla incorporated a CAPTCHA on their login page, it is no longer possible to authenticate using your own UI. Instead, you must use an integrated browser to show the Tesla login page and process the result.

The Test.WPF project demonstrates a complete login and refresh flow. The sample only runs on Windows, but the library itself is cross platform (e.g. works on Xamarin).

The steps to use this library are as follows:

  1. Initialise a TeslaAuthHelper instance
  2. Call authHelper.GetLoginUrlForBrowser() to generate the login URL
  3. Show the returned URL in your app's integrated browser
  4. Monitor the browser until you see a request for a URL containing the string "void/callback"
  5. Grab the entire URL (it contains a query string) and pass it to authHelper.GetTokenAfterLoginAsync()
  6. This will return a Tokens object containing an Access and Refresh token
  7. When the token expires, call authHelper.RefreshTokenAsync() to get a new one without needing a complete login flow.

teslaauth's People

Contributors

tomhollander avatar ramonsmits avatar briangru avatar jesperkuipers avatar

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.