You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I cannot go further the step of getting the partner token.
It does not appear in the URL (node '&code=') however, a code appears in the error page with a copy button, which I used as a code. Tried several times but failed each time. Any help welcome ! Here is the trace (private info hidden):
$ python main.py
Welcome to the guided tour of the tesla_api library
Registering a developer account
Please go to the following URL and register a developer account and your app (Python program): https://developer.tesla.com/
Press [Enter] to continue, when registration is complete or to cancel...
OpenSSL 1.1.1g FIPS 21 Apr 2020
The keys already exist in the directory 'lib/tesla_api/TeslaKeys'
Please push the public key 'lib/tesla_api/TeslaKeys/com.tesla.3p.public-key.pem' to your domain at the following URL: https://xxxx.com/.well-known/appspecific/com.tesla.3p.public-key.pem
optional: put the php script 'tesla_api/WWW-example/index.php' to your https://xxx.com/ directory to ease the code retrieval for later customer registration
Press Enter to continue, when the public key is pushed...
Getting the partner token...
Registering the partner account and domain .com
log Debug Tesla Command url: /api/1/partner_accounts
log Debug response status: 412, Precondition Failed, {"response":null,"error":"Root domain .com must match registered allowed origin on https://developer.tesla.com/dashboard/app-details/","error_description":"","txid":""}
return value register partner account: None
Something went wrong during registration, check logging
log Error The file tesla_tokens.json was not found.
The token file does not yet exist - we register the customer account now...
web-browser opened with URL: https://auth.tesla.com/oauth2/v3/authorize?&client_id=&locale=en-US&prompt=login&redirect_uri=https:///&response_type=code&scope=openid%20offline_access%20user_data%20vehicle_device_data%20vehicle_cmds%20vehicle_charging_cmds%20energy_device_data%20energy_cmds&state=e7002213af7560aba03a1ebc3c782ec5
complete registration and watch, if the following random number is not disturbed in the response.
e7002213af7560aba03a1ebc3c782ec5
Next step is to exchange the Code for tokens.
You find the code in the URL, the tesla server redirects you to.
The page likely shows a 400 Bad Request, this is normal
The code can be found between &code and &state in the url
Please enter the 'code' from the URL:
--- token data {'error': 'invalid_auth_code', 'error_description': 'The authorization code is invalid. It may have already been used or expired. Request a new sign in session to generate a new code.', 'referenceID': . For more information, visit: https://developer.tesla.com/docs/fleet-api#help-and-support'}
Traceback (most recent call last):
File "main.py", line 118, in
tesla_api.tesla_register_customer(myTesla)
File "lib/tesla_api/tesla_api_2024.py", line 517, in tesla_register_customer
myTesla.exchange_code_for_tokens(myTesla.client_id, CLIENT_SECRET, user_input_code)
File "lib/tesla_api/tesla_api_2024.py", line 165, in exchange_code_for_tokens
expiry_time = datetime.datetime.now() + datetime.timedelta(seconds=token_data.get('expires_in'))
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
TypeError: unsupported type for timedelta seconds component: NoneType
$
The text was updated successfully, but these errors were encountered:
I managed to get it working a few days ago, but the instructions regarding '/'s in config.py seemed the wrong way around for the lines 13 and 14: tesla_redirected_domain and tesla_redirect_uri
I ended up with the format below:
tesla_redirect_domain = "xxx.yyy.zzz/" # NO https:// !!!
tesla_redirect_uri = "https://xxx.yyy.zzz/cgi-bin/ProcessToken.py" # start with https:// and include a tailing '/'!
I do not speak php so used a python script to extract my token but index.php should work just as well
I cannot go further the step of getting the partner token.
It does not appear in the URL (node '&code=') however, a code appears in the error page with a copy button, which I used as a code. Tried several times but failed each time. Any help welcome ! Here is the trace (private info hidden):
$ python main.py
Welcome to the guided tour of the tesla_api library
Registering a developer account
Please go to the following URL and register a developer account and your app (Python program):
https://developer.tesla.com/
Press [Enter] to continue, when registration is complete or to cancel...
OpenSSL 1.1.1g FIPS 21 Apr 2020
The keys already exist in the directory 'lib/tesla_api/TeslaKeys'
Please push the public key 'lib/tesla_api/TeslaKeys/com.tesla.3p.public-key.pem' to your domain at the following URL:
https://xxxx.com/.well-known/appspecific/com.tesla.3p.public-key.pem
optional: put the php script 'tesla_api/WWW-example/index.php' to your https://xxx.com/ directory to ease the code retrieval for later customer registration
Press Enter to continue, when the public key is pushed...
Getting the partner token...
Registering the partner account and domain .com
log Debug Tesla Command url: /api/1/partner_accounts
log Debug response status: 412, Precondition Failed, {"response":null,"error":"Root domain .com must match registered allowed origin on https://developer.tesla.com/dashboard/app-details/","error_description":"","txid":""}
return value register partner account: None
Something went wrong during registration, check logging
log Error The file tesla_tokens.json was not found.
The token file does not yet exist - we register the customer account now...
web-browser opened with URL:
https://auth.tesla.com/oauth2/v3/authorize?&client_id=&locale=en-US&prompt=login&redirect_uri=https:///&response_type=code&scope=openid%20offline_access%20user_data%20vehicle_device_data%20vehicle_cmds%20vehicle_charging_cmds%20energy_device_data%20energy_cmds&state=e7002213af7560aba03a1ebc3c782ec5
complete registration and watch, if the following random number is not disturbed in the response.
e7002213af7560aba03a1ebc3c782ec5
Next step is to exchange the Code for tokens.
You find the code in the URL, the tesla server redirects you to.
The page likely shows a 400 Bad Request, this is normal
The code can be found between &code and &state in the url
Please enter the 'code' from the URL:
--- token data {'error': 'invalid_auth_code', 'error_description': 'The authorization code is invalid. It may have already been used or expired. Request a new sign in session to generate a new code.', 'referenceID': . For more information, visit: https://developer.tesla.com/docs/fleet-api#help-and-support'}
Traceback (most recent call last):
File "main.py", line 118, in
tesla_api.tesla_register_customer(myTesla)
File "lib/tesla_api/tesla_api_2024.py", line 517, in tesla_register_customer
myTesla.exchange_code_for_tokens(myTesla.client_id, CLIENT_SECRET, user_input_code)
File "lib/tesla_api/tesla_api_2024.py", line 165, in exchange_code_for_tokens
expiry_time = datetime.datetime.now() + datetime.timedelta(seconds=token_data.get('expires_in'))
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
TypeError: unsupported type for timedelta seconds component: NoneType
$
The text was updated successfully, but these errors were encountered: