Tesla api token

Tesla api token DEFAULT

Tesla API Access Token Generator

* YES this now supports the new Tesla authentication as of late January 2021, including 2-factor authentication.

Enter your Tesla.com username and password to generate a Tesla API token. This can be used to give an API key to 3rd party apps like TeslaFi, Tasker Plugin for Tesla, Tesla Widget, TezLab, A Better Route Planner (ABRP), or many others.

This will not store your username or password anywhere, and it's not transmitted to anywhere else but Tesla. I already have a Tesla, I don't care about yours. I just made this for my personal usage, but anyone can feel free to use it. However, note that this goes against current OAuth2 recommendations and submitting your username & password to ANY third party is generally considered a "bad idea". Unfortunately Tesla doesn't give you a way to do this directly on their website.

As with all Tesla API tokens, if you want to invalidate this one, just change your password on Tesla.com.

Sours: https://home.hasslers.net/teslaapi/

Authentication

description

The authentication process for the Tesla API

This is a work in progress

Tesla has deprecated the endpoint in favor of using . I'm working on updating the documentation as soon as possible. This documentation is still missing handling for MFA users. Feel free to discuss this in issue #260.

Tesla uses a separate SSO service (auth.tesla.com) for authentication across their app and website. This service is designed around a browser-based flow using OAuth 2.0, but also appears to have support for Open ID Connect. This supports both obtaining an access token and refreshing it as it expires.

{% hint style="warning" %} Tesla's SSO service has a WAF (web application firewall) that may temporarily block you if you make repeated, execessive requests. This is to prevent bots from attacking the service, either as a brute force or denial-of-service attack. This normally presents as a "challenge" page, which requires running some non-trivial JavaScript code to validate that you have a full browser engine available. While you can potentially fully evaluate this page to remove the block, the best practice for now is to reduce your calls to the SSO service to a minimum and avoid things like automatic request retries. {% endhint %}

Logging in

Step 1: Obtain the login page

Subsequent requests to the SSO service will require a "code verifier" and "code challenge". These are a random 86-character alphanumeric string and its SHA-256 hash encoded in URL-safe base64 (base64url). Here is an example of generating them in Ruby, but you can apply this same process to other languages.

code_verifier=random_string(86)code_challenge=Base64.urlsafe_encode64(Digest::SHA256.hexdigest(code_verifier))

You will also need a stable value for requests, which is a random string of any length.

Avoid setting a header that looks like a browser (such as Chrome or Safari). The SSO service has protections in place that will require executing JavaScript if a browser-like user agent is detected.

GET

The first request returns HTML intended for display in the browser. You will need to parse this HTML for hidden input fields.

The request is made with a of "https://auth.tesla.com/void/callback", which is a non-existent page. The Tesla app intercepts the request to this page to capture the authorization code.

Request parameters
FieldTypeExampleDescription
String, requiredThe OAuth client ID. Always "ownerapi"
String, requiredThe "code challenge"
String, requiredThe code challenge hash method. Always "S256" (SHA-256)
String, requiredThe redirect URL. Always "https://auth.tesla.com/void/callback"
String, requiredThe type of expected response. Always "code"
String, requiredThe authentication scope. Always "openid email offline_access"
String, requiredThe OAuth state value. Any random string.
String, optionalThe email for the authenticating Tesla account
Response

This returns an HTML response body. There will be a with hidden elements that contain session-based information to prevent CSRF attacks. At the moment, they appear to be , , , , and , but they may change due to server-side changes by Tesla. These must be provided in the POST body to validate the following request.

The response will also include a header that includes a session ID cookie. This should be provided to the following request as a header so that the SSO service can match up your request with private data it has in that session.

When the optional parameter is supplied with the request and the email is registered with a Tesla SSO service in another region this will respond with a 303 HTTP response code (See Other), which will redirect you to the Tesla SSO service in that region (e.g. auth.tesla.cn). Should this redirect happen you should continue using the region specific Tesla SSO host name in all subsequent steps. Easy way to test this is to use with using an email registered under .

Step 2: Obtain an authorization code

This will simulate a user submitting the form from the previous request in their browser. Ensure that the hidden s are provided as POST body parameters and the header is set.

POST

Cookie: {cookie value from set-cookie header}
Request parameters

Note: These are query parameters, not part of the POST body

FieldTypeExampleDescription
String, requiredThe OAuth client ID. Always "ownerapi"
String, requiredThe "code challenge"
String, requiredThe code challenge hash method. Always "S256" (SHA-256)
String, requiredThe redirect URL. Always "https://auth.tesla.com/void/callback"
String, requiredThe type of expected response. Always "code"
String, requiredThe authentication scope. Always "openid email offline_access"
String, requiredThe OAuth state value. Any random string.

Note: This is the contents of the POST body. These should be form encoded ().

FieldTypeExampleDescription
hidden input namesString[], requiredhidden input valuesThe fields from the HTML's hidden s
String, requiredThe email for the authenticating Tesla account
String, requiredThe password for the authenticating Tesla account
Response

This will respond with a 302 HTTP response code, which will attempt to redirect to the redirect_uri with additional query parameters added. This new URL is located in the header. You should not follow it, as it is non-existent. Instead, you should parse this URL and extract the query parameter, which is your authorization code.

Location: https://auth.tesla.com/void/callback?code=c7dc7f8196d001632558d6632558d6243632558d6b6d60f82c0632558d67&state=aGZzZGpzZnNk&issuer=https%3A%2F%2Fauth.tesla.com%2Foauth2%2Fv3

Step 3: Exchange authorization code for bearer token

POST

This is a standard OAuth 2.0 Authorization Code exchange. This endpoint uses JSON for the request and response bodies.

Request parameters
FieldTypeExampleDescription
String, requiredTThe type of OAuth grant. Always "authorization_code"
String, requiredThe OAuth client ID. Always "ownerapi"
String, requiredThe authorization code from the last request.
String, requiredThe code verifier string generated previously.
String, requiredThe redirect URL. Always "https://auth.tesla.com/void/callback"
{ "grant_type": "authorization_code", "client_id": "ownerapi", "code": "123", "code_verifier": "123", "redirect_uri": "https://auth.tesla.com/void/callback" }
Response
{ "access_token": "eyJaccess", "refresh_token": "eyJrefresh", "expires_in": 300, "state": "of the union", "token_type": "Bearer" }

Step 4: Exchange bearer token for access token

POST

This endpoint follows RFC 7523 to exchange a JWT access token from the SSO service for an access token usable by the Owner API.

The current client ID and secret are available here.

You will get back an which is treated as an OAuth 2.0 Bearer Token. This token is passed along in an header with all future requests:

Authorization: Bearer {access_token}

The access token has a 45 day expiration.

Request parameters

Important: Ensure you are using the from the SSO service here. The returned access_token is for all other requests to the Owner API.

Authorization: Bearer {access_token}
FieldTypeExampleDescription
String, requiredThe type of OAuth grant. Always "urn:ietf:params:oauth:grant-type:jwt-bearer"
String, requiredThe OAuth client ID
String, requiredThe OAuth client secret
Request
{ "grant_type": "urn:ietf:params:oauth:grant-type:jwt-bearer", "client_id": "abc", "client_secret": "123" }
Response
{ "access_token": "abc123", "token_type": "bearer", "expires_in": 3888000, "refresh_token": "cba321", "created_at": 1538359034 }

Refreshing an access token

POST

This uses the SSO from Step 3 above to do an OAuth 2.0 Refresh Token Grant. This does not work with the provided by the Owner API. Those have no use currently and should be discarded.

This refreshed access token can be used with the Owner API to obtain a new access token for that service using the exact same request as Step 4 above.

This endpoint uses JSON for the request and response bodies.

Should your Owner API token begin with you should POST to Tesla SSO service to have it refresh. Owner API tokens starting with are to be refreshed using

Request parameters
FieldTypeExampleDescription
String, requiredThe type of OAuth grant. Always "refresh_token"
String, requiredThe OAuth client ID. Always "ownerapi"
String, requiredThe refresh token from a prior authentication.
String, requiredThe authentication scope. Always "openid email offline_access"
{ "grant_type": "refresh_token", "client_id": "ownerapi", "refresh_token": "eyJrefresh", "scope": "openid email offline_access" }
Response
{ "access_token": "eyJaccess", "refresh_token": "eyJrefresh", "id_token": "id", "expires_in": 300, "token_type": "Bearer" }
Sours: https://github.com/timdorr/tesla-api/blob/master/docs/api-basics/authentication.md
  1. Opposite of affection
  2. Erie county taxes
  3. Deviantart icon link
  4. Spiceworks help desk

timdorr / tesla-api Public

Here's a complete working script created by @ralfonso4 in this thread: #283

(I've only fixed a case-sensitivity bug in the header.) Edit: Apparently the header is lowercase or uppercase depending on the platform. I've updated this script to pull whichever one is present, using @ralfonso4's fix.

Just change at the very bottom your and to your tesla.com credentials and it will generate your access and refresh tokens.

Confirmed to work in TeslaFi.com.

Edit. For those of you finding this through google, here's how to make it work on a Mac (similar for other *nix).

  1. Copy the script below into a text file like .
  2. Change the login and password to your tesla.com credentials (this is only ever saved in this text file and sent to tesla.com).
  3. Open Terminal.app and type (with the space), then drag the file you created into the Terminal window. That will populate the complete path to the script.
  4. Hit enter and it will dump out a mess of values. Your refresh token is between the quotes after .
<?phpclassTesla { protected$apiBaseUrl = "https://owner-api.teslamotors.com/api/1"; protected$tokenUrl = 'https://owner-api.teslamotors.com/oauth/token'; protected$tokenUrlNew = 'https://auth.tesla.com/oauth2/v3/token'; protected$accessUrl = 'https://auth.tesla.com/oauth2/v3/authorize'; protected$accessToken; protected$vehicleId = null; publicfunction__construct(string$accessToken = null) { $this->accessToken = $accessToken; } publicfunctionsetAccessToken(string$accessToken) { $this->accessToken = $accessToken; } publicfunctionallData() { return$this->sendRequest('/vehicle_data')['response']; } publicfunctionvehicles() { return$this->sendRequest('/vehicles'); } publicfunctionvehicle() { return$this->sendRequest('')['response']; } publicfunctionsetVehicleId(int$vehicleId) { $this->vehicleId = $vehicleId; } publicfunctionsetClientId(string$clientId) { putenv('TESLA_CLIENT_ID=' . $clientId); } publicfunctionsetClientSecret(string$clientSecret) { putenv('TESLA_CLIENT_SECRET=' . $clientSecret); } publicfunctionmobileEnabled() { return$this->sendRequest('/mobile_enabled')['response']; } publicfunctionchargeState() { return$this->sendRequest('/data_request/charge_state')['response']; } publicfunctionclimateState() { return$this->sendRequest('/data_request/climate_state')['response']; } publicfunctiondriveState() { return$this->sendRequest('/data_request/drive_state')['response']; } publicfunctionguiSettings() { return$this->sendRequest('/data_request/gui_settings')['response']; } publicfunctionvehicleState() { return$this->sendRequest('/data_request/vehicle_state')['response']; } publicfunctionvehicleConfig() { return$this->sendRequest('/data_request/vehicle_config')['response']; } publicfunctionwakeUp() { return$this->sendRequest('/wake_up', [], 'POST')['response']; } publicfunctionstartSoftwareUpdate( int$seconds = 0 ) { return$this->sendRequest('/command/schedule_software_update', [ 'offset_sec' => $seconds ], 'POST')['response']; } publicfunctionsetValetMode(bool$active = false, int$pin = 0000) { $params = [ 'on' => $active, 'pin' => $pin ]; return$this->sendRequest('/command/set_valet_mode', $params, 'POST')['response']; } publicfunctionresetValetPin() { return$this->sendRequest('/command/reset_valet_pin', [], 'POST')['response']; } publicfunctionopenChargePort() { return$this->sendRequest('/command/charge_port_door_open', [], 'POST')['response']; } publicfunctionsetChargeLimitToStandard() { return$this->sendRequest('/command/charge_standard', [], 'POST')['response']; } publicfunctionsetChargeLimitToMaxRange() { return$this->sendRequest('/command/charge_max_range', [], 'POST')['response']; } publicfunctionsetChargeLimit(int$percent = 90) { $params = [ 'percent' => "$percent" ]; return$this->sendRequest('/command/set_charge_limit', $params, 'POST')['response']; } publicfunctionstartCharging() { return$this->sendRequest('/command/charge_start', [], 'POST')['response']; } publicfunctionstopCharging() { return$this->sendRequest('/command/charge_stop', [], 'POST')['response']; } publicfunctionflashLights() { return$this->sendRequest('/command/flash_lights', [], 'POST')['response']; } publicfunctionhonkHorn() { return$this->sendRequest('/command/honk_horn', [], 'POST')['response']; } publicfunctionunlockDoors() { return$this->sendRequest('/command/door_unlock', [], 'POST')['response']; } publicfunctionlockDoors() { return$this->sendRequest('/command/door_lock', [], 'POST')['response']; } publicfunctionwindowControl(string$state = 'close', int$lat = 0, int$lon = 0) { return$this->sendRequest('/command/window_control', [ 'command' => $state, 'lat' => $lat, 'lon' => $lon ], 'POST')['response']; } publicfunctionsetTemperature(float$driverDegreesCelcius = 20.0, float$passengerDegreesCelcius = 20.0) { return$this->sendRequest('/command/set_temps?driver_temp=' . $driverDegreesCelcius . '&passenger_temp=' . $passengerDegreesCelcius, [], 'POST')['response']; } publicfunctionstartHvac() { return$this->sendRequest('/command/auto_conditioning_start', [], 'POST')['response']; } publicfunctionstopHvac() { return$this->sendRequest('/command/auto_conditioning_stop', [], 'POST')['response']; } publicfunctionmovePanoramicRoof(string$state = 'vent', int$percent = 50) { return$this->sendRequest('/command/sun_roof_control?state=' . $state . '&percent=' . $percent, [], 'POST')['response']; } publicfunctionremoteStart(string$password = '') { return$this->sendRequest('/command/remote_start_drive?password=' . $password, [], 'POST')['response']; } publicfunctionopenTrunk() { return$this->sendRequest('/command/actuate_trunk', [ 'which_trunk' => 'rear' ], 'POST')['response']; } publicfunctionopenFrunk() { return$this->sendRequest('/command/actuate_trunk', [ 'which_trunk' => 'front' ], 'POST')['response']; } publicfunctionsetNavigation(string$location) { $params = [ 'type' => 'share_ext_content_raw', 'value' => [ 'android.intent.extra.TEXT' => $location ], 'locale' => 'en-US', 'timestamp_ms' => time(), ]; return$this->sendRequest('/command/navigation_request', $params, 'POST')['response']; } publicfunctionstartSentry() { return$this->sendRequest('/command/set_sentry_mode', [ 'on' => True], 'POST')['response']; } publicfunctionstopSentry() { return$this->sendRequest('/command/set_sentry_mode', [ 'on' => False], 'POST')['response']; } publicfunctionsetSeatHeater(int$heater = 0, int$level = 0) { return$this->sendRequest('/command/remote_seat_heater_request', ['heater' => $heater, 'level' => $level], 'POST')['response']; } publicfunctionsetTemps(float$driver = 21.0, float$passenger = 21.0) { return$this->sendRequest('/command/set_temps', ['driver_temp' => $driver, 'passenger_temp' => $passenger], 'POST')['response']; } publicfunctionbase64url_encode($data) { returnrtrim(strtr(base64_encode($data), '+/', '-_'), '='); } publicfunctiongetAccessToken(string$username, string$password) { ###Step 1: Obtain the login page$code_verifier = substr(hash('sha512', mt_rand()), 0, 86); $state = $this->base64url_encode(substr(hash('sha256', mt_rand()), 0, 12)); $code_challenge = $this->base64url_encode($code_verifier); $data =[ 'client_id' => 'ownerapi', 'code_challenge' => $code_challenge, 'code_challenge_method' => 'S256', 'redirect_uri' => 'https://auth.tesla.com/void/callback', 'response_type' => 'code', 'scope' => 'openid email offline_access', 'state' => $state, ]; $GetUrl = $this->accessUrl.'?'.http_build_query ($data); $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, $GetUrl); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); curl_setopt($ch, CURLOPT_TIMEOUT, 30); curl_setopt($ch, CURLOPT_HEADER, 1); $apiResult = curl_exec($ch); curl_close($ch); $dom = newDomDocument(); @ $dom->loadHTML($apiResult); $child_elements = $dom->getElementsByTagName('input'); //DOMNodeListforeach( $child_elementsas$h2 ) { $hiddeninputs[$h2->getAttribute('name')]=$h2->getAttribute('value'); } $headers = []; $output = rtrim($apiResult); $data = explode("\n",$output); $headers['status'] = $data[0]; array_shift($data); foreach($dataas$part){ //some headers will contain ":" character (Location for example), and the part after ":" will be lost, Thanks to @Emanuele$middle = explode(":",$part,2); //Supress warning message if $middle[1] does not exist, Thanks to @crayonsif ( !isset($middle[1]) ) { $middle[1] = null; } $headers[trim($middle[0])] = trim($middle[1]); } if (isset($headers['Set-Cookie'])){ $cookie = $headers['Set-Cookie']; } elseif (isset($headers['set-cookie'])){ $cookie = $headers['set-cookie']; } ###Step 2: Obtain an authorization code$ch = curl_init(); curl_setopt($ch, CURLOPT_URL, $GetUrl); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); curl_setopt($ch, CURLOPT_TIMEOUT, 30); curl_setopt($ch, CURLOPT_HEADER, 1); curl_setopt($ch, CURLOPT_POST, true); curl_setopt($ch, CURLOPT_HTTPHEADER, array('Content-Type: application/x-www-form-urlencoded','Cookie: '.$cookie)); $postData = array( '_csrf' => $hiddeninputs['_csrf'], '_phase' => $hiddeninputs['_phase'], '_process' => $hiddeninputs['_process'], 'transaction_id' => $hiddeninputs['transaction_id'], 'cancel' =>$hiddeninputs['cancel'], 'identity' => $username, 'credential' => $password ); curl_setopt($ch, CURLOPT_POSTFIELDS, http_build_query($postData)); curl_setopt($ch, CURLOPT_COOKIE, $cookie); $apiResult = curl_exec($ch); curl_close($ch); #print_r($apiResult);$code= explode('&',explode('https://auth.tesla.com/void/callback?code=',$apiResult)[1])[0]; #print 'CODE'.$code;###Step 3: Exchange authorization code for bearer token$ch = curl_init(); curl_setopt($ch, CURLOPT_URL, $this->tokenUrlNew); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); curl_setopt($ch, CURLOPT_TIMEOUT, 30); curl_setopt($ch, CURLOPT_POST, true); curl_setopt($ch, CURLOPT_HTTPHEADER, [ 'Content-Type: application/json', 'Accept: application/json', 'User-Agent: Mozilla/5.0 (Linux; Android 9.0.0; VS985 4G Build/LRX21Y; wv) AppleWebKit/537.36 (KHTML, like Gecko) Version/4.0 Chrome/58.0.3029.83 Mobile Safari/537.36', 'X-Tesla-User-Agent: TeslaApp/3.4.4-350/fad4a582e/android/9.0.0', ]); curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode([ 'grant_type' => 'authorization_code', 'client_id' => 'ownerapi', 'code' => $code, 'code_verifier' => $code_verifier, 'redirect_uri' => 'https://auth.tesla.com/void/callback' ])); $apiResult = curl_exec($ch); curl_close($ch); $apiResultJson = json_decode($apiResult, true); $BearerToken = $apiResultJson['access_token']; $RefreshToken = $apiResultJson['refresh_token']; ###Step 4: Exchange bearer token for access token$ch = curl_init(); curl_setopt($ch, CURLOPT_URL, $this->tokenUrl); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); curl_setopt($ch, CURLOPT_TIMEOUT, 30); curl_setopt($ch, CURLOPT_POST, true); curl_setopt($ch, CURLOPT_HTTPHEADER, [ 'Authorization: Bearer '.$BearerToken, 'Content-Type: application/json' ]); curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode([ 'grant_type' => 'urn:ietf:params:oauth:grant-type:jwt-bearer', 'client_id' => getenv('TESLA_CLIENT_ID'), 'client_secret' => getenv('TESLA_CLIENT_SECRET'), ])); $apiResult = curl_exec($ch); curl_close($ch); $apiResultJson = json_decode($apiResult, true); $apiResultJson['refresh_token']=$RefreshToken; #print_r($apiResultJson);exit;$this->accessToken = $apiResultJson['access_token']; return$apiResultJson; } publicfunctionrefreshAccessToken(string$refreshToken) { $tesla = newTesla(); $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, 'https://pastebin.com/raw/pS7Z6yyP'); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); $result = curl_exec($ch); curl_close($ch); $api = explode(PHP_EOL,$result); $id=explode('=',$api[0]); $secret=explode('=',$api[1]); $tesla->setClientId(trim($id[1])); $tesla->setClientSecret(trim($secret[1])); $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, $this->tokenUrlNew); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); curl_setopt($ch, CURLOPT_TIMEOUT, 30); curl_setopt($ch, CURLOPT_POST, true); curl_setopt($ch, CURLOPT_HTTPHEADER, [ 'Content-Type: application/json', 'Accept: application/json', 'User-Agent: Mozilla/5.0 (Linux; Android 9.0.0; VS985 4G Build/LRX21Y; wv) AppleWebKit/537.36 (KHTML, like Gecko) Version/4.0 Chrome/58.0.3029.83 Mobile Safari/537.36', 'X-Tesla-User-Agent: TeslaApp/3.4.4-350/fad4a582e/android/9.0.0', ]); #print 'XX '.getenv('TESLA_CLIENT_ID');exit;curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode([ 'grant_type' => 'refresh_token', 'client_id' => 'ownerapi', 'client_secret' => getenv('TESLA_CLIENT_SECRET'), 'refresh_token' => $refreshToken, 'scope' => 'openid email offline_access' ])); $apiResult = curl_exec($ch); $apiResultJson = json_decode($apiResult, true); curl_close($ch); #print_r($apiResult);exit;$apiResultJson = json_decode($apiResult, true); $BearerToken = $apiResultJson['access_token']; $RefreshToken = $apiResultJson['refresh_token']; ###Step 4: Exchange bearer token for access token$ch = curl_init(); curl_setopt($ch, CURLOPT_URL, $this->tokenUrl); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); curl_setopt($ch, CURLOPT_TIMEOUT, 30); curl_setopt($ch, CURLOPT_POST, true); curl_setopt($ch, CURLOPT_HTTPHEADER, [ 'Authorization: Bearer '.$BearerToken, 'Content-Type: application/json' ]); curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode([ 'grant_type' => 'urn:ietf:params:oauth:grant-type:jwt-bearer', 'client_id' => getenv('TESLA_CLIENT_ID'), 'client_secret' => getenv('TESLA_CLIENT_SECRET'), ])); $apiResult = curl_exec($ch); curl_close($ch); $apiResultJson = json_decode($apiResult, true); $apiResultJson['refresh_token']=$RefreshToken; #print_r($apiResultJson);exit;$this->accessToken = $apiResultJson['access_token']; return$apiResultJson; } protectedfunctionsendRequest(string$endpoint, array$params = [], string$method = 'GET') { $ch = curl_init(); if ($endpoint !== '/vehicles' && ! is_null($this->vehicleId)) { $endpoint = '/vehicles/' . $this->vehicleId . $endpoint; } curl_setopt($ch, CURLOPT_URL, $this->apiBaseUrl . $endpoint); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); curl_setopt($ch, CURLOPT_TIMEOUT, 30); curl_setopt($ch, CURLOPT_HEADER, false); curl_setopt($ch, CURLOPT_HTTPHEADER, [ 'Content-Type: application/json', 'Accept: application/json', 'User-Agent: Mozilla/5.0 (Linux; Android 9.0.0; VS985 4G Build/LRX21Y; wv) AppleWebKit/537.36 (KHTML, like Gecko) Version/4.0 Chrome/58.0.3029.83 Mobile Safari/537.36', 'X-Tesla-User-Agent: TeslaApp/3.4.4-350/fad4a582e/android/9.0.0', 'Authorization: Bearer ' . $this->accessToken, ]); if ($method == 'POST' || $method == 'PUT' || $method == 'DELETE') { if ($method == 'POST') { curl_setopt($ch, CURLOPT_POST, true); } if (in_array($method, ['PUT', 'DELETE'])) { curl_setopt($ch, CURLOPT_CUSTOMREQUEST, $method); } curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($params)); } $apiResult = curl_exec($ch); $headerInfo = curl_getinfo($ch); $apiResultJson = json_decode($apiResult, true); curl_close($ch); $result = []; if ($apiResult === false) { $result['errorcode'] = 0; $result['errormessage'] = curl_error($ch); //print $result['errormessage'].' api<br>'; } if (! in_array($headerInfo['http_code'], ['200', '201', '204'])) { $result['errorcode'] = $headerInfo['http_code']; if (isset($apiResult)) { $result['errormessage'] = $apiResult; } //print $result['errormessage'].' header<br>';; } return$apiResultJson ?? $apiResult; } } $t = newTesla(); $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, 'https://pastebin.com/raw/pS7Z6yyP'); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); $result = curl_exec($ch); $api = explode(PHP_EOL,$result); $id=explode('=',$api[0]); $secret=explode('=',$api[1]); $t->setClientId(trim($id[1])); $t->setClientSecret(trim($secret[1])); var_dump($t->getAccessToken("login", "password")); ?>
Sours: https://github.com/timdorr/tesla-api/discussions/288

OpenEnergyMonitor Community

In early August, my Tesla Access Token failed to automatically update and so days later it expired. This then stopped Inputs to emoncms from the Tesla EV – soc, battery range miles and odometer reading.
And the reason?

With a great deal of help from others, I now have a working solution which is in two parts.

Part 1 which is described in the Python script below involves a free Android App to copy and save the data. And it is possible just to use Part 1 every 30 or so days.

I do not have an iPhone but this looks like the Apple equivalent App:

App Store

‎Auth app for Tesla

‎Need to generate modern secure Tesla API authentication tokens? Look no further! Based on the proven implementation of Watch app for Tesla, now you can continue to keep all your custom shortcuts alive, by swapping out your previous token mechanism...

Part 2 which is described in the Python script below, saves the key data to files – Access Token, Expiry Date and SSO Refresh Token. The script can then be set to run monthly in the background using Cron – until Tesla makes the next change, that is :frowning_face:

Hope this helps

1 Like

Sours: https://community.openenergymonitor.org/t/tesla-access-tokens-update/18493

Token tesla api

Just trust me baby, okay. Tina nodded mechanically, looking at him in dismay. The car stopped at a sauna located in some dead ends and nooks. Yegor took Tina out of the car and took her inside. The girl, shackled by fear, did not even try to escape, it was unrealistic to escape from the.

Tesla changed their API authentication process AGAIN and broke my code!

Postman Pavel, looked closely at a letter personally to Colonel Pyotr, full of pleasant suggestions. Come, wrote the lovely Polina, let's talk, dream, dance, take a walk, visit a half-forgotten, half-overgrown pond, go fishing. Come, Petrusha, to visit as soon as possible, we'll be lucky, we'll have a good time, potency will require constant verification.

Dear Colonel.

You will also be interested:

Well, come on, fuck me, Margot hypnotized the girl's eyes, but she again decided to play: With specially emphasized movements she untied the bra straps and in a. Second her delicious breasts in all their glory became available for viewing. Margot admired the third size and the small areolas around the nipples, which protruded invitingly like glass cutters.

The masseuse bent down and began rubbing, like a cat, on the hot vagina of a languishing girl with her magic tits, trying to penetrate her nipples. Into the innermost hole.



353 354 355 356 357