mercedes_me_api
mercedes_me_api copied to clipboard
Token generation with "Invalid client credentials."
Situation:
- Running script on Mac
- Mercedes Me API v0.12
Steps:
- Created a config file with the right developer credentials (ID, Secret and VIN).
- Run script, which generates a URL
- Copy the generated code when requested
- 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.
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
then above you should see something like this:
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
$ 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
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.
could you try with the pyton script?
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...
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
I've got the same issue.
You have missed configobj module.
Install it with pip3 command:
pip3 install configobj
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/
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.
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)
Had the exact same issue also and solved it using the python script. Something's definitely wrong with the bash one.
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 :)