CJNE / pyporscheconnectapi

Python client library for Porsche Connect API
MIT License
44 stars 9 forks source link

List of vehicles returns 401 (unauthorized) #4

Closed fredriklj closed 2 years ago

fredriklj commented 2 years ago

When trying to list available vehicles, the API responds with 401 (Unauthorized). This error was not caught, and causes an error in line 161 of connection.py, as it only expects a JSON object.

Trying to debug this, it seems the list call has moved to

https://api.porsche.com/core/api/v3/se/sv_SE/vehicles

Haven't had time to investigate further, so can't provide a PR. But updating getVehicles in client.py and changing line 47–59 of connection.py to this got my integration in hass to start working again:

'portal': {
    'client_id': 'TZ4Vf5wnKeipJxvatJ60lPHYEzqZ4WNp',
    'redirect_uri': 'https://my-static02.porsche.com/static/cms/auth.html',
    'prefix': 'https://api.porsche.com/core'
},
'carcontrol': {
    'client_id': 'imeVsv86TpjM9beWJqI0sNMAip6ga05O',
    'redirect_uri': 'https://my.porsche.com/myservices/auth/auth.html',
    'prefix': 'https://api.porsche.com/service-vehicle'
} 

Best, Fredrik

fredriklj commented 2 years ago

Quickly ran through the available commands and found that climate control and charge control also seem to have moved, new URI seem to be:

https://api.porsche.com/e-mobility/{country.lower()}/{language.lower()}_{country.upper()}/{vin}/toggle-direct-climatisation/{action}

https://api.porsche.com/e-mobility/{country.lower()}/{language.lower()}_{country.upper()}/{model}/{vin}/toggle-direct-charging/{action}
CJNE commented 2 years ago

Thank you for this! Will fix asap :)