Skip to content

C# / .NET core library for authenticating to Tesla's Owner API

License

Notifications You must be signed in to change notification settings

sumitkgarg/TeslaAuth

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

31 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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

Usage example is in the test.csproj project, but it's basically just this:

// When it's time to authenticate:
var authHelper = new TeslaAuthHelper("YourUserAgent/1.0");
var tokens = await authHelper.AuthenticateAsync(username, password, mfaCode);
Console.WriteLine("Access token: " + tokens.AccessToken);
Console.WriteLine("Refresh token: " + tokens.RefreshToken);

// When it's time to refresh:
var newToken = await authHelper.RefreshTokenAsync(tokens.RefreshToken);

About

C# / .NET core library for authenticating to Tesla's Owner API

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • C# 100.0%