zabuldon / teslajsonpy

Apache License 2.0
57 stars 62 forks source link

Older Owner API is broken in 3.10 #459

Closed llamafilm closed 8 months ago

llamafilm commented 8 months ago

Unfortunately the recent update to 3.10 broke compatibility with the older Owner API. When trying to refresh a token it logs error:

DEBUG:teslajsonpy.connection:Refreshing access token with refresh_token
INFO:httpx:HTTP Request: POST https://auth.tesla.com/oauth2/v3/token "HTTP/1.1 400 Bad Request"
DEBUG:teslajsonpy.connection:Unable to refresh sso oauth token
DEBUG:teslajsonpy.connection:Auth returned {'error': 'unauthorized_client', 'error_description': "We don't recognize this client_id and client_secret combination", 'referenceID': '1087fe4b-7d7c-42c2-ba59-a54661e9b2d0-1709448104988'}

I will push PR for this shortly. The below code can be used to reproduce the issue

import asyncio, httpx, logging
from teslajsonpy import Controller

logging.basicConfig(level=logging.INFO)
logging.getLogger("teslajsonpy").setLevel(logging.DEBUG)

EMAIL = 'xxxxx'
REFRESH_TOKEN = 'xxxxx'

async def main():
    async_client = httpx.AsyncClient()
    controller = Controller(
        async_client,
        email=EMAIL,
        refresh_token=REFRESH_TOKEN,
    )

    await controller.connect()

asyncio.run(main())