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.
The package is available via NuGet with the package name TeslaAuth.
Install-Package TeslaAuth
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);