pyze icon indicating copy to clipboard operation
pyze copied to clipboard

Error communicating with Renault API

Open timmchugh11 opened this issue 4 years ago • 35 comments
trafficstars

Hello,

About 2 days ago my connection stopped working and I get the error,

Error communicating with Renault API! {"error":"access_denied","error_description":"Unauthorized"}

Is this an issue with pyze? I have tried re adding my credentials and I get the same error when logging in.

I am still able to use the Renault app and the data is up to date, so I don't think it is my account.

Thanks

timmchugh11 avatar Feb 03 '21 18:02 timmchugh11

There was a change of Key on the Renault servers. There is a discussion about it on https://github.com/hacf-fr/renault-api/issues/181, with corresponding pull request https://github.com/hacf-fr/renault-api/pull/182

epenet avatar Feb 03 '21 19:02 epenet

Thank you, I just used the new key and all is working again

The key I used from the link you sent, Ae9FDWugRxZQAGm3Sxgk7uJn6Q4CGEA2

timmchugh11 avatar Feb 03 '21 20:02 timmchugh11

Hmm, I got it working again with the new key, but it seems to have broken again?

Error message seems to be slightly different though. When using the new key (mentioned above), I get this error: {"type":"FUNCTIONAL","messages":[{"code":"err.func.wired.unauthorized","message":"The access is unauthorized"}],"errors":[{"errorCode":"err.func.wired.unauthorized","errorMessage":"The access is unauthorized"}],"error_reference":"FUNCTIONAL"}

While when I use a different/incorrect key, I get this error: {"error":"access_denied","error_description":"Unauthorized"}

Any ideas? The My Renault app on my phone still functions correctly...

yannickh avatar Feb 08 '21 18:02 yannickh

Problem maybe related to https://github.com/jamesremuscat/pyze/issues/78?

db-EV avatar Feb 08 '21 20:02 db-EV

Note: https://github.com/hacf-fr/renault-api still works, but in my case the data hasn't changed since 2021-02-07T12:17:58+01:00 and no longer reflects the reality.

epenet avatar Feb 08 '21 21:02 epenet

Ok, I found the problem in EVCC code. Was not a problem on Renaults side... So API (with updated Kamereon key) still works fine here. After vehicle wakeup the data was updated correctly.

Yes, it seems to be some faulty Gigya integrations out there.

db-EV avatar Feb 08 '21 21:02 db-EV

Ok, I found the problem in EVCC code. Was not a problem on Renaults side... So API (with updated Kamereon key) still works fine here. After vehicle wakeup the data was updated correctly.

Yes, it seems to be some faulty Gigya integrations out there.

Starting with today 12:00 CET gigya changed (or never accepted) some parameter-names. See (sorry german) https://github.com/fungus75/ioBroker.zoe2/issues/17 or have a look at the implementation of the gigya-part here: https://github.com/hacf-fr/renault-api/issues

fungus75 avatar Feb 08 '21 21:02 fungus75

Please find here which parameter I had to adjust: https://github.com/fungus75/ioBroker.zoe2/commit/c787fda42de51d7f7df4a087706ed1a67e55cd9c

fungus75 avatar Feb 08 '21 21:02 fungus75

And calling account.getAccount is unnecessary, it's enough with accounts.login and accounts.getJWT. You get the needed gigyaPersonID already on login.

db-EV avatar Feb 08 '21 21:02 db-EV

And it was not the case for pyze either, there are other scripts, apps and so on with faulty Gigya integration.

db-EV avatar Feb 08 '21 21:02 db-EV

So what's the fix to have pyze working again? Obviously some people digged into the problem.

kozmoz avatar Feb 09 '21 10:02 kozmoz

In the Gigya calls (getAccountInfo and getJWT), the parameter "oauth_token" should be changed to "login_token".

yannickh avatar Feb 09 '21 10:02 yannickh

So what's the fix to have pyze working again? Obviously some people digged into the problem.

@kozmoz you don't describe your problem so it might not be linked to this discussion

In the Gigya calls (getAccountInfo and getJWT), the parameter "oauth_token" should be changed to "login_token".

@yannickh it is already the case in pyze since #79 was merged last year

epenet avatar Feb 09 '21 10:02 epenet

So what's the fix to have pyze working again? Obviously some people digged into the problem.

@kozmoz you don't describe your problem so it might not be linked to this discussion

Exactly the same error as @timmchugh11 who started this issue.

Error communicating with Renault API! {"error":"access_denied","error_description":"Unauthorized"}

kozmoz avatar Feb 09 '21 10:02 kozmoz

You need to update the Kamereon API key!!!

premultiply avatar Feb 09 '21 10:02 premultiply

Alright. Missed the new key for Kamereon, but did update the Gigya API key. In summary, this fixed my issue:

export KAMEREON_API_KEY="Ae9FDWugRxZQAGm3Sxgk7uJn6Q4CGEA2"
export GIGYA_API_KEY="3_e8d4g4SE_Fo8ahyHwwP7ohLGZ79HKNN2T8NjQqoNnk6Epj6ilyYwKdHUyCw3wuxz"

kozmoz avatar Feb 09 '21 10:02 kozmoz

I'm still facing issues:

Traceback (most recent call last):
  File "/opt/bin/pyze", line 8, in <module>
    sys.exit(main())
  File "/volume1/Share/Web/SmartHome/.local/lib/python3.8/site-packages/pyze/cli/__main__.py", line 69, in main
    parsed_args.func(parsed_args)
  File "/volume1/Share/Web/SmartHome/.local/lib/python3.8/site-packages/pyze/cli/status.py", line 35, in run
    v = get_vehicle(parsed_args)
  File "/volume1/Share/Web/SmartHome/.local/lib/python3.8/site-packages/pyze/cli/common.py", line 24, in get_vehicle
    vehicles = k.get_vehicles().get('vehicleLinks')
  File "/volume1/Share/Web/SmartHome/.local/lib/python3.8/site-packages/pyze/api/credentials.py", line 26, in inner
    return func(*args, **kwargs)
  File "/volume1/Share/Web/SmartHome/.local/lib/python3.8/site-packages/pyze/api/kamereon.py", line 114, in get_vehicles
    self.get_account_id(),
  File "/volume1/Share/Web/SmartHome/.local/lib/python3.8/site-packages/pyze/api/kamereon.py", line 73, in get_account_id
    accounts = self.get_accounts()
  File "/volume1/Share/Web/SmartHome/.local/lib/python3.8/site-packages/pyze/api/credentials.py", line 25, in inner
    raise MissingCredentialException(name)
pyze.api.credentials.MissingCredentialException: gigya-person-id

any ideas?

brusch avatar Feb 11 '21 09:02 brusch

Same here; pi@TestPi:~/pyze$ pyze status --km

Traceback (most recent call last): File "/usr/local/bin/pyze", line 11, in load_entry_point('PyZE==0.5.0', 'console_scripts', 'pyze')() File "/usr/local/lib/python3.5/dist-packages/PyZE-0.5.0-py3.5.egg/pyze/cli/main.py", line 69, in main File "/usr/local/lib/python3.5/dist-packages/PyZE-0.5.0-py3.5.egg/pyze/cli/status.py", line 35, in run File "/usr/local/lib/python3.5/dist-packages/PyZE-0.5.0-py3.5.egg/pyze/cli/common.py", line 24, in get_vehicle File "/usr/local/lib/python3.5/dist-packages/PyZE-0.5.0-py3.5.egg/pyze/api/credentials.py", line 26, in inner File "/usr/local/lib/python3.5/dist-packages/PyZE-0.5.0-py3.5.egg/pyze/api/kamereon.py", line 119, in get_vehicles File "/usr/local/lib/python3.5/dist-packages/PyZE-0.5.0-py3.5.egg/pyze/api/credentials.py", line 26, in inner File "/usr/local/lib/python3.5/dist-packages/PyZE-0.5.0-py3.5.egg/pyze/api/gigya.py", line 109, in get_jwt_token File "/usr/local/lib/python3.5/dist-packages/PyZE-0.5.0-py3.5.egg/pyze/api/gigya.py", line 126, in raise_gigya_errors RuntimeError: Gigya returned error 403007: Invalid namespace 'accounts' or method 'getJWT' or you do not have the required permissions to call it.

Used the mentioned api keys from above and from keys mentioned in the readme files

Podariss avatar Feb 12 '21 11:02 Podariss

Are you using the correct Gigya API keys for your country? These are different for each country. Only the Kamereon API key is static for all countries.

db-EV avatar Feb 12 '21 11:02 db-EV

I used the GB version before, but even with nl_NL no change...

Podariss avatar Feb 12 '21 13:02 Podariss

Hi, i had the same issue and now it workes with the keys of kozmos. Then i played a bit with the keys. Here are my results: the Gigya-key is not so strikt, for me also the english and the german version worked: English

	"gigyaProd": {
		"target": "https://accounts.eu1.gigya.com",
		"apikey": "3_e8d4g4SE_Fo8ahyHwwP7ohLGZ79HKNN2T8NjQqoNnk6Epj6ilyYwKdHUyCw3wuxz"

German

    "gigyaProd": {
        "target": "https://accounts.eu1.gigya.com",
        "apikey": "3_7PLksOyBRkHv126x5WhHb-5pqC1qFR8pQjxSeLB6nhAnPERTUlwnYoznHSxwX668"

but the Kamereon Key is bitchy: neither the german nor the english version was successfull. Here i got the error message:

"Error communicating with Renault API! {"error":"access_denied","error_description":"Unauthorized"}"

Only the Kammereon key of kozmos worked. So a question to him: how did you get this key?

berti2911 avatar Feb 12 '21 13:02 berti2911

Key retrieval has changed on the Renault side. It is now hidden deep inside Firebase, and for now you need to use Fiddler to extract it.

There is a discussion on https://github.com/hacf-fr/renault-api/pull/184

epenet avatar Feb 12 '21 13:02 epenet

@Podariss, @brusch: maybe it helps to delete first the lokal file .credentials/pyze.json before starting again with pyze login?

berti2911 avatar Feb 12 '21 13:02 berti2911

Only the Kammereon key of kozmos worked. So a question to him: how did you get this key?

In the third message of this thread. Initially I also missed that one, but later I realised that was the fix for access_denied.

https://github.com/jamesremuscat/pyze/issues/95#issuecomment-772813562

kozmoz avatar Feb 12 '21 14:02 kozmoz

Same Problem here:

Traceback (most recent call last): File "/usr/local/bin/pyze", line 11, in <module> load_entry_point('PyZE==0.5.0', 'console_scripts', 'pyze')() File "/usr/local/lib/python3.7/dist-packages/PyZE-0.5.0-py3.7.egg/pyze/cli/__main__.py", line 69, in main File "/usr/local/lib/python3.7/dist-packages/PyZE-0.5.0-py3.7.egg/pyze/cli/status.py", line 35, in run File "/usr/local/lib/python3.7/dist-packages/PyZE-0.5.0-py3.7.egg/pyze/cli/common.py", line 24, in get_vehicle File "/usr/local/lib/python3.7/dist-packages/PyZE-0.5.0-py3.7.egg/pyze/api/credentials.py", line 25, in inner pyze.api.credentials.MissingCredentialException: kamereon-api-key

heckmic avatar Feb 22 '21 11:02 heckmic

@Heckmic: Did you use exactly the following KEY? Only this one worked for me. export KAMEREON_API_KEY="Ae9FDWugRxZQAGm3Sxgk7uJn6Q4CGEA2"

And of course you have to login again: pyze login

berti2911 avatar Feb 22 '21 15:02 berti2911

I am using the updated key Ae9FDWugRxZQAGm3Sxgk7uJn6Q4CGEA2 , but I am still getting this error:

{"type":"FUNCTIONAL","messages":[{"code":"err.func.wired.unauthorized","message":"The access is unauthorized"}],"errors":[{"errorCode":"err.func.wired.unauthorized","errorMessage":"The access is unauthorized"}],"error_reference":"FUNCTIONAL"}

I am using both direct url call and GET/POST using a Rest API Chrome extension, no luck.

My direct link: https://api-wired-prod-1-euw1.wrd-aws.com/commerce/v1/persons/MY_PERSON_ID?apikey=Ae9FDWugRxZQAGm3Sxgk7uJn6Q4CGEA2&x-gigya-id_token=MY_JWT_TOKEN&country=IT

jumpjack avatar Sep 21 '21 11:09 jumpjack

I also know that there is a direct link which gives a very long JSON response, containing a lot of data, including my VIN.... but I found it by chance after dozens of attempts and I cannot get it anymore, any idea how it could be formed?

jumpjack avatar Sep 21 '21 11:09 jumpjack

Are you using pyze? If not maybe you could download this library and look in the code how the web-service or link is formed. For pyze it is essential to delete first the file .credentials/pyze.json and then login again with "pyze login" to avoid old chaching.

berti2911 avatar Sep 21 '21 12:09 berti2911

Indeed I am reverse-engineering pyze and other scripts to figure out which are the direct calls to perform, to implement them in Javascript, but I am stuck at Kamereon authentication (Gigya part is fine).

jumpjack avatar Sep 21 '21 12:09 jumpjack