alandtse / tesla

Tesla custom integration for Home Assistant. This requires a refresh token be generated by third-party apps to login.
Apache License 2.0
597 stars 99 forks source link

Unable to Setup account for Tesla Custom Integration due to Unable to communicate with Tesla API: UNKNOWN_ERROR_451 #691

Closed rpeng6 closed 1 year ago

rpeng6 commented 1 year ago

Dear All i am tesla user in China and currently i am trying to get my tesla to work it HA but after installation and input all the user info i am getting the error "Unable to communicate with Tesla API: UNKNOWN_ERROR_45151" i have tried changing the authentication website from .com to .cn but still does not work and give this error and help or guidance will be highly appricated.

Logger: custom_components.tesla_custom Source: custom_components/tesla_custom/init.py:195 Integration: Tesla Custom Integration (documentation, issues) First occurred: 8:55:15 AM (1 occurrences) Last logged: 8:55:15 AM

Unable to communicate with Tesla API: UNKNOWN_ERROR_451

alandtse commented 1 year ago

We will need debug logs to be able to tell what this is. I've never seen a 451, but it may be some restriction in China. https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/451

rpeng6 commented 1 year ago

Thank you for the response, will try to get the debug log for detail support btw Teslamate is working not sure this information is useful


From: Alan Tse @.> Sent: Sunday, August 27, 2023 8:22:00 AM To: alandtse/tesla @.> Cc: rpeng6 @.>; Author @.> Subject: Re: [alandtse/tesla] Unable to Setup account for Tesla Custom Integration due to Unable to communicate with Tesla API: UNKNOWN_ERROR_451 (Issue #691)

We will need debug logs to be able to tell what this is. I've never seen a 451, but it may be some restriction in China. https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/451

— Reply to this email directly, view it on GitHubhttps://github.com/alandtse/tesla/issues/691#issuecomment-1694530530, or unsubscribehttps://github.com/notifications/unsubscribe-auth/AU4YC3NYQM6MESRX37EY2E3XXKHKRANCNFSM6AAAAAA32WJUU4. You are receiving this because you authored the thread.Message ID: @.***>

jok3r007 commented 1 year ago

"/usr/local/lib/python3.11/site-packages/teslajsonpy/controller.py", line 1348, in api 2023-09-05 18:43:49.263 ERROR (MainThread) [custom_components.tesla_custom] Unable to communicate with Tesla API: UNKNOWN_ERROR_451

rpeng6 commented 1 year ago

We will need debug logs to be able to tell what this is. I've never seen a 451, but it may be some restriction in China. https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/451

hi alandtse here is the debug log, seems the problem is residing in permission in accessing the website "https://owner-api.teslamotors.com/api/1/products" is there any work around or address update that needed to be made

2023-09-06 14:49:17.032 DEBUG (MainThread) [teslajsonpy.connection] Connecting with existing access token 2023-09-06 14:49:17.033 DEBUG (MainThread) [teslajsonpy.controller] 402 endpoints loaded 2023-09-06 14:49:17.034 DEBUG (MainThread) [teslajsonpy.connection] Token expiration in -6 days, 23:06:13 2023-09-06 14:49:17.034 DEBUG (MainThread) [teslajsonpy.connection] Oauth expiration detected 2023-09-06 14:49:17.034 DEBUG (MainThread) [teslajsonpy.connection] Refreshing access token with refresh_token 2023-09-06 14:49:17.582 DEBUG (MainThread) [teslajsonpy.connection] Saved new auth info {'access_token': 'token removed', 'expires_in': 1694040557} 2023-09-06 14:49:17.582 DEBUG (MainThread) [teslajsonpy.connection] Successfully refreshed oauth 2023-09-06 14:49:17.583 DEBUG (MainThread) [teslajsonpy.connection] get: https://owner-api.teslamotors.com/api/1/products {} 2023-09-06 14:49:22.683 DEBUG (MainThread) [teslajsonpy.connection] 451: {"response":null,"error":"user not allowed in region","error_description":""} 2023-09-06 14:49:23.940 DEBUG (MainThread) [teslajsonpy.connection] Token expiration in 7:59:54 2023-09-06 14:49:23.940 DEBUG (MainThread) [teslajsonpy.connection] get: https://owner-api.teslamotors.com/api/1/products {} 2023-09-06 14:49:24.177 DEBUG (MainThread) [teslajsonpy.connection] 451: {"response":null,"error":"user not allowed in region","error_description":""} 2023-09-06 14:49:26.873 DEBUG (MainThread) [teslajsonpy.connection] Token expiration in 7:59:51 2023-09-06 14:49:26.873 DEBUG (MainThread) [teslajsonpy.connection] get: https://owner-api.teslamotors.com/api/1/products {} 2023-09-06 14:49:27.095 DEBUG (MainThread) [teslajsonpy.connection] 451: {"response":null,"error":"user not allowed in region","error_description":""} 2023-09-06 14:49:31.746 DEBUG (MainThread) [teslajsonpy.connection] Token expiration in 7:59:46 2023-09-06 14:49:31.746 DEBUG (MainThread) [teslajsonpy.connection] get: https://owner-api.teslamotors.com/api/1/products {} 2023-09-06 14:49:32.219 DEBUG (MainThread) [teslajsonpy.connection] 451: {"response":null,"error":"user not allowed in region","error_description":""} 2023-09-06 14:49:32.219 ERROR (MainThread) [custom_components.tesla_custom] Unable to communicate with Tesla API: UNKNOWN_ERROR_451

alandtse commented 1 year ago

If you're based in CN, you have to use the right domain. Are you using auth.tesla.cn when setting up the integration?

rpeng6 commented 1 year ago

yes I am but I still get this error


From: Alan Tse @.> Sent: Thursday, September 7, 2023 3:54:32 PM To: alandtse/tesla @.> Cc: rpeng6 @.>; Author @.> Subject: Re: [alandtse/tesla] Unable to Setup account for Tesla Custom Integration due to Unable to communicate with Tesla API: UNKNOWN_ERROR_451 (Issue #691)

If you're based in CN, you have to use the right domain. Are you using auth.tesla.cn when setting up the integration?

— Reply to this email directly, view it on GitHubhttps://github.com/alandtse/tesla/issues/691#issuecomment-1709653788, or unsubscribehttps://github.com/notifications/unsubscribe-auth/AU4YC3NHCCWDVQUHUWRMV7LXZF4TRANCNFSM6AAAAAA32WJUU4. You are receiving this because you authored the thread.Message ID: @.***>

rpeng6 commented 1 year ago

If you're based in CN, you have to use the right domain. Are you using auth.tesla.cn when setting up the integration?

alandtse seem the problem is at getting connection to owner-api.teslamotors.com did a little research and it seems that china based tesla need to go to "owner-api.vn.cloud.tesla.cn" so i am not sure where i can modify the original address to the correct one, below i have added the link for API and the debug log and help is highly appreciated.

https://tesla-api.timdorr.com/api-basics/authentication

debug log 2023-09-08 12:11:18.920 WARNING (MainThread) [homeassistant.config_entries] Config entry 'xx' for tesla_custom integration could not authenticate 2023-09-08 12:13:17.015 ERROR (MainThread) [custom_components.tesla_custom] Unable to communicate with Tesla API: UNKNOWN_ERROR_451 2023-09-08 12:13:42.816 DEBUG (MainThread) [teslajsonpy.controller] 402 endpoints loaded 2023-09-08 12:13:42.816 DEBUG (MainThread) [teslajsonpy.connection] Token expiration in -19609 days, 11:46:18 2023-09-08 12:13:42.816 DEBUG (MainThread) [teslajsonpy.connection] Oauth expiration detected 2023-09-08 12:13:42.816 DEBUG (MainThread) [teslajsonpy.connection] Refreshing access token with refresh_token 2023-09-08 12:13:43.025 DEBUG (MainThread) [teslajsonpy.connection] Saved new auth info {'access_token': '', 'expires_in': 1694204022} 2023-09-08 12:13:43.025 DEBUG (MainThread) [teslajsonpy.connection] Successfully refreshed oauth 2023-09-08 12:13:43.025 DEBUG (MainThread) [teslajsonpy.connection] get: https://owner-api.teslamotors.com/api/1/products {} 2023-09-08 12:13:43.780 DEBUG (MainThread) [teslajsonpy.connection] 451: {"response":null,"error":"user not allowed in region","error_description":""} 2023-09-08 12:13:44.923 DEBUG (MainThread) [teslajsonpy.connection] Token expiration in 7:59:59 2023-09-08 12:13:44.923 DEBUG (MainThread) [teslajsonpy.connection] get: https://owner-api.teslamotors.com/api/1/products {} 2023-09-08 12:13:45.170 DEBUG (MainThread) [teslajsonpy.connection] 451: {"response":null,"error":"user not allowed in region","error_description":""} 2023-09-08 12:13:47.651 DEBUG (MainThread) [teslajsonpy.connection] Token expiration in 7:59:56 2023-09-08 12:13:47.652 DEBUG (MainThread) [teslajsonpy.connection] get: https://owner-api.teslamotors.com/api/1/products {} 2023-09-08 12:13:47.900 DEBUG (MainThread) [teslajsonpy.connection] 451: {"response":null,"error":"user not allowed in region","error_description":""} 2023-09-08 12:13:52.333 DEBUG (MainThread) [teslajsonpy.connection] Token expiration in 7:59:51 2023-09-08 12:13:52.333 DEBUG (MainThread) [teslajsonpy.connection] get: https://owner-api.teslamotors.com/api/1/products {} 2023-09-08 12:13:52.562 DEBUG (MainThread) [teslajsonpy.connection] 451: {"response":null,"error":"user not allowed in region","error_description":""} 2023-09-08 12:13:57.817 DEBUG (MainThread) [teslajsonpy.connection] Token expiration in 7:59:46 2023-09-08 12:13:57.817 DEBUG (MainThread) [teslajsonpy.connection] get: https://owner-api.teslamotors.com/api/1/products {} 2023-09-08 12:13:58.536 DEBUG (MainThread) [teslajsonpy.connection] 451: {"response":null,"error":"user not allowed in region","error_description":""} 2023-09-08 12:13:58.537 ERROR (MainThread) [custom_components.tesla_custom] Unable to communicate with Tesla API: UNKNOWN_ERROR_451

rpeng6 commented 1 year ago

@alandtse Hi alandtse seem the problem is at getting connection to owner-api.teslamotors.com did a little research and it seems that china based tesla need to go to "owner-api.vn.cloud.tesla.cn" so i am not sure where i can modify the original address to the correct one, below i have added the link for API and the debug log and help is highly appreciated.

https://tesla-api.timdorr.com/api-basics/authentication

tidaybreak commented 4 months ago

@rpeng6 解决了吗,最后怎么做的?

skipishere commented 4 months ago

@tidaybreak as this issue is closed since last year, if you still problems please open a new issue.