flobz / psa_car_controller

Control psa car with connected_car v4 API.
GNU General Public License v3.0
404 stars 214 forks source link

30.5: OIDC error #153

Closed thommierother closed 3 years ago

thommierother commented 3 years ago

Today thes PSA API was throwing OIDC errors:

root@raspi04:/opt/psacc# /usr/bin/python3 /opt/psacc/server.py -f config.json -c charge_config1.json -r
  2021-05-30 11:34:29,686 :: INFO :: server start
  MyPeugeot email: t.rother@netzwissen.de
  MyPeugeot password:
  Traceback (most recent call last):
    File "/opt/psacc/server.py", line 65, in <module>
      web.app.myp.refresh_token()
    File "/opt/psacc/my_psacc.py", line 114, in refresh_token
      self.manager._refresh_token()
    File "/usr/local/lib/python3.7/dist-packages/oauth2_client/credentials_manager.py", line 179, in _refresh_token
      raise err
    File "/usr/local/lib/python3.7/dist-packages/oauth2_client/credentials_manager.py", line 173, in _refresh_token
      self._token_request(payload, False)
    File "/usr/local/lib/python3.7/dist-packages/oauth2_client/credentials_manager.py", line 190, in _token_request
      CredentialManager._handle_bad_response(response)
    File "/usr/local/lib/python3.7/dist-packages/oauth2_client/credentials_manager.py", line 78, in _handle_bad_response
      raise OAuthError(HTTPStatus(response.status_code), error.get('error'), error.get('error_description'))
  oauth2_client.credentials_manager.OAuthError: 400  - invalid_grant : grant is invalid

  During handling of the above exception, another exception occurred:

  Traceback (most recent call last):
    File "/opt/psacc/server.py", line 73, in <module>
      web.app.myp.connect(client_email, client_password)
    File "/opt/psacc/my_psacc.py", line 62, in connect
      self.manager.init_with_user_credentials_realm(user, password, self.realm)
    File "/opt/psacc/libs/oauth.py", line 20, in init_with_user_credentials_realm
      self._token_request(self._grant_password_request_realm(login, password, realm), True)
    File "/usr/local/lib/python3.7/dist-packages/oauth2_client/credentials_manager.py", line 190, in _token_request
      CredentialManager._handle_bad_response(response)
    File "/usr/local/lib/python3.7/dist-packages/oauth2_client/credentials_manager.py", line 78, in _handle_bad_response
      raise OAuthError(HTTPStatus(response.status_code), error.get('error'), error.get('error_description'))
  oauth2_client.credentials_manager.OAuthError: 400  - invalid_grant : The provided access grant is invalid, expired, or revoked.
  2021-05-30 11:35:04,697 :: INFO :: save config change
Flodu31 commented 3 years ago

Hello, I’ve exactly the same issue. A restart of the service and everything works for 24 hours. And same error again.

thommierother commented 3 years ago

It looks like a token expiration

2021-05-30 12:09:56,129 :: ERROR :: retry last request, token was expired

But after some time wehave a new access token and then it works again

2021-05-30 12:11:56,653 :: INFO :: {"access_token": "9f74acda-1ddf-424f-9c62-769a4b199713", "customer_id": "AP-ACNT100008187646", "correlation_id": "072e6ac72b8f400cb187a35b7b2fbe6420210530101156653", "req_date": "2021-05-30T10:11:56Z", "vin": "VR3UHZKXZMT032161", "req_parameters": {"action": "state"}}

flobz commented 3 years ago

it's was psa fault.