Skip to content

Commit

Permalink
fix: fix china authentication
Browse files Browse the repository at this point in the history
  • Loading branch information
alandtse committed Apr 3, 2021
1 parent f109ad8 commit 45dec97
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 6 deletions.
8 changes: 4 additions & 4 deletions poetry.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ aiohttp = "^3.7.4"
backoff = "^1.10.0"
beautifulsoup4 = "^4.9.3"
wrapt = "^1.12.1"
authcaptureproxy = "~=0.7.1"
authcaptureproxy = "~=0.8.1"

[tool.poetry.dev-dependencies]
flake8 = "^3.9.0"
Expand Down
2 changes: 1 addition & 1 deletion teslajsonpy/const.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,6 @@
DRIVING_INTERVAL = 60 # interval when driving detected
WEBSOCKET_TIMEOUT = 11 # time for websocket to timeout
RELEASE_NOTES_URL = "https://teslascope.com/teslapedia/software/"
AUTH_DOMAIN = "https://auth.tesla.cn"
AUTH_DOMAIN = "https://auth.tesla.com"
API_URL = "https://owner-api.teslamotors.com"
WS_URL = "wss://streaming.vn.teslamotors.com/streaming"
8 changes: 8 additions & 0 deletions teslajsonpy/teslaproxy.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@

from aiohttp import ClientResponse, web
from authcaptureproxy import AuthCaptureProxy, return_timer_countdown_refresh_html
from authcaptureproxy.const import SKIP_AUTO_HEADERS
from authcaptureproxy.examples.modifiers import find_regex_urls
from authcaptureproxy.helper import prepend_url
import multidict
Expand Down Expand Up @@ -58,6 +59,7 @@ def __init__(self, proxy_url: URL, host_url: URL) -> None:
},
}
)
self.redirect_filters = {"url": ["^.*/static/404.html$"]}

async def test_url(
self,
Expand Down Expand Up @@ -170,6 +172,11 @@ async def modify_headers(
) -> multidict.MultiDict:
"""Modify headers.
Return modified headers based on site and request. To disable auto header generation,
pass in a key const.SKIP_AUTO_HEADERS with a list of keys to not generate.
For example, to prevent User-Agent generation: {SKIP_AUTO_HEADERS : ["User-Agent"]}
Args:
site (URL): URL of the next host request.
request (web.Request): Proxy directed request. This will need to be changed for the actual host request.
Expand All @@ -180,6 +187,7 @@ async def modify_headers(
"""
result = await super().modify_headers(site, request)
method = request.method
result.update({SKIP_AUTO_HEADERS: ["User-Agent"]})
if (
str(site.path) == "/oauth2/v3/authorize/mfa/verify"
and method == "POST"
Expand Down

0 comments on commit 45dec97

Please sign in to comment.