sieth wrote: ↑Monday 31 August 2020 18:42
Ok, so clearly I did something wrong than.
I've included some screenshot's maybe someone else can see my mistake.
merc1.jpg
I see you have 3 of the 5 BYOCAR licenses added to your profile. Add EV (even if you don't have an EV) and Pay-as-you-Drive.
sieth wrote: ↑Monday 31 August 2020 18:42
merc2.jpg
Looks ok. Just to double check: username contains both the
client_id AND
client_secret with a
colon in between?
sieth wrote: ↑Monday 31 August 2020 18:42
merc3.jpg
Nice
![Smile :)](./images/smilies/icon_e_smile.gif)
With each change in licenses (and/or when some time (few hours) has passed) you need to re-do this to get a new authorization code as the current/old ones expires.
sieth wrote: ↑Monday 31 August 2020 18:42
This is the errors i've got:
2020-08-31 18:40:41.819 Status: Received 400/401.. During authorisation proces. Aborting!
2020-08-31 18:40:41.819 Status: Mercedes: Aborting due to too many failed authentication attempts (and prevent getting blocked)!
2020-08-31 18:40:41.819 Status: Mercedes: Worker stopped...
2020-08-31 18:40:41.819 Error: MercApi: Failed to get token.
2020-08-31 18:40:41.819 Error: MercApi: Failed to refresh login credentials.
I've been curious what mistake i'm making here
At the above log is indeed saying that the authorization process fails.
At the moment the process is not really user-friendly yet (trying to work on that
![Embarrassed :oops:](./images/smilies/icon_redface.gif)
).
The 'missing' step, I will update the docs asap, is that although the setup screen already says that you need to enter the
Authorisation code you received (which you did in screenshot 3), you still have to enter the 'refresh token' (or you can enter the refreshtoken within the 'user variables', see
setup/more options/user variables). Therefor you need to perform one more step once you have a valid Authorisation code:
Code: Select all
curl --location --request POST 'https://api.secure.mercedes-benz.com/oidc10/auth/oauth/v2/token' \
--header 'Authorization: Basic <BASE64 Encoded client_id:client_secret>' \
--header 'Content-Type: application/x-www-form-urlencoded' \
--data-urlencode 'code=<PUT_YOUR_AUTHORISATION_CODE_HERE>' \
--data-urlencode 'redirect_uri=https://localhost' \
--data-urlencode 'grant_type=authorization_code'
The above command (you can run it on your PI or most other shells) has 2 items to fill-in correctly. The AUTHORISATION_CODE from the previous step. And a base64 encoded representation of the string you entered in the 'username' field of the setup screen. You can use base64encode.org (privacy mode just to be sure) or a command like
Code: Select all
echo '<client_id>:<client_secret>' | base64
The curl command should return JSON output with contains several things including an access_token and refresh_token. The refresh_token value is the one that you have to enter. When you press 'update' in the setup screen, Domoticz will restart the Mercedes Me hardware and the new value will be used. Within the log you should see a log message stating that login was succesful (and for now also logs the new refresh_token it received and stored internally).
I hope to remove the need for this step asap and let the program take care of this.