mercedes_me_api icon indicating copy to clipboard operation
mercedes_me_api copied to clipboard

Token generation with "Invalid client credentials."

Open harrolf opened this issue 2 years ago • 12 comments

Situation:

  • Running script on Mac
  • Mercedes Me API v0.12

Steps:

  1. Created a config file with the right developer credentials (ID, Secret and VIN).
  2. Run script, which generates a URL
  3. Copy the generated code when requested
  4. Process finishes without errors and the token file is created

.mercedeme_token content: {"error":"invalid_client","error_description":"Invalid client credentials."}

It seems to be an obvious description in the file, however I'm not able to solve it.

harrolf avatar Jan 11 '23 13:01 harrolf

Hi, sorry for read that. could you please check into the console ( https://developer.mercedes-benz.com/console) if you can see your project with the right permissions? you should see something like this

image

then above you should see something like this:

image

be sure that you have localhos as redirect url. then use that cliend id and client secret in the configuration file. let me know please. i've just tried now with my configuration and it worked for me. thanks

xraver avatar Jan 11 '23 21:01 xraver

$ cat .mercedesme_config CLIENT_ID= -> should be the same shown in the console page CLIENT_SECRET= -> one generated in the same page VEHICLE_ID= -> your vin id

if you have issue generate another one

xraver avatar Jan 11 '23 21:01 xraver

Thank you @xraver,

I have confirmed again and all is exactly the same. I did create a new secret which unfortunately didn't change the result.

I tried to rename the .mercedes_config file or leave the values empty, and it complained that it was missing the file or properties. So that part looks correct. It also generates the .mercedes_token_ file however with the invalid credentials content.

harrolf avatar Jan 11 '23 21:01 harrolf

could you try with the pyton script?

xraver avatar Jan 11 '23 21:01 xraver

I did some test: if I try to generate token with wrong client id i have issue in the web page. if I try to generate token with wrong client password i have the following token

{"error":"invalid_request","error_description":"Invalid client or client credentials."}

the error that you have is something different...

xraver avatar Jan 12 '23 02:01 xraver

could you try with the pyton script?

My apologies, I tried to run the python script, however it runs into an error:

$ python3 mercedes_me_api.py -t
Traceback (most recent call last):
  File "/mercedes_me/mercedes_me_api.py", line 13, in <module>
    from config import MercedesMeConfig
  File "/mercedes_me/config.py", line 12, in <module>
    from configobj import ConfigObj
ModuleNotFoundError: No module named 'configobj'

Hence I used the shell script which does generate the (invalid) token file.

Here's an overview of the folder:

$ ls -al
total 168
drwxrwxr-x@  19 <user_name>  staff   608 Jan 12 13:03 .
drwx------@ 206 <user_name>  staff  6592 Jan 11 15:26 ..
-rw-r--r--@   1 <user_name>  staff  6148 Jan 12 13:03 .DS_Store
drwxrwxr-x@   3 <user_name>  staff    96 Dec 20 00:19 .github
-rw-rw-r--@   1 <user_name>  staff    76 Dec 20 00:19 .gitignore
-rw-r--r--@   1 <user_name>  staff   184 Jan 11 14:36 .mercedesme_config
-rw-r--r--    1 <user_name>  staff    77 Jan 11 15:29 .mercedesme_token
-rw-rw-r--@   1 <user_name>  staff  1071 Dec 20 00:19 LICENSE
-rw-rw-r--@   1 <user_name>  staff  7131 Dec 20 00:19 README.md
-rw-rw-r--@   1 <user_name>  staff  2013 Dec 20 00:19 config.py
-rw-rw-r--@   1 <user_name>  staff   901 Dec 20 00:19 const.py
drwxrwxr-x@   4 <user_name>  staff   128 Jan 10 13:43 custom_components
-rw-rw-r--@   1 <user_name>  staff    68 Dec 20 00:19 hacs.json
-rw-rw-r--@   1 <user_name>  staff  4845 Dec 20 00:19 info.md
-rw-rw-r--@   1 <user_name>  staff  2723 Dec 20 00:19 mercedes_me_api.py
-rwxr-xr-x@   1 <user_name>  staff  5970 Dec 20 00:19 mercedes_me_api.sh
-rw-rw-r--@   1 <user_name>  staff  5256 Dec 20 00:19 oauth.py
-rw-rw-r--@   1 <user_name>  staff  3150 Dec 20 00:19 query.py
-rw-rw-r--@   1 <user_name>  staff  8098 Dec 20 00:19 resources.py

harrolf avatar Jan 12 '23 12:01 harrolf

I've got the same issue. You have missed configobj module. Install it with pip3 command: pip3 install configobj

Redwid avatar Jan 30 '23 16:01 Redwid

If you will have issue that this module still can't be found, then try to use virtual env: https://packaging.python.org/en/latest/guides/installing-using-pip-and-virtual-environments/

Redwid avatar Jan 30 '23 16:01 Redwid

Thank you very much! That was it.

It actually worked with the python script!

However the shell script still failed. It produced an {"error":"invalid_request","error_description":"Invalid client or client credentials."} token.

harrolf avatar Jan 30 '23 18:01 harrolf

Thanks ! Had the same issue, got it resolved following these steps... (using the python script rather than the shell script)

(had to do 1 more - pip3 install request for some reason)

lantranbot avatar Mar 01 '23 21:03 lantranbot

Had the exact same issue also and solved it using the python script. Something's definitely wrong with the bash one.

d3v3l15h avatar Mar 17 '23 07:03 d3v3l15h

Probably I found the bug in the bash script: Line 24 REDIRECT_URL="https://localhost" should be REDIRECT_URL="http://localhost"

Before I did this change I was not forwarded to the Mercedes me site, where I could accept the access to my cars data. After I changed https: to http: I was forwarded and could accept as expected. Finally I got the the error page with the URL line with the famous code in it :)

sigma415 avatar May 12 '23 18:05 sigma415