Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Token generation with "Invalid client credentials." #37

Open
harrolf opened this issue Jan 11, 2023 · 12 comments
Open

Token generation with "Invalid client credentials." #37

harrolf opened this issue Jan 11, 2023 · 12 comments

Comments

@harrolf
Copy link

harrolf commented Jan 11, 2023

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.

@xraver
Copy link
Owner

xraver commented Jan 11, 2023 via email

@xraver
Copy link
Owner

xraver commented Jan 11, 2023

$ 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

@harrolf
Copy link
Author

harrolf commented Jan 11, 2023

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.

@xraver
Copy link
Owner

xraver commented Jan 11, 2023 via email

@xraver
Copy link
Owner

xraver commented Jan 12, 2023

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...

@harrolf
Copy link
Author

harrolf commented Jan 12, 2023

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

@Redwid
Copy link

Redwid commented Jan 30, 2023

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

@Redwid
Copy link

Redwid commented Jan 30, 2023

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/

@harrolf
Copy link
Author

harrolf commented Jan 30, 2023

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.

@lantranbot
Copy link

lantranbot commented Mar 1, 2023

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)

@d3v3l15h
Copy link

d3v3l15h commented Mar 17, 2023

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

@sigma415
Copy link

sigma415 commented May 12, 2023

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 :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants