opened 10:53PM - 20 Jun 22 UTC
bug
The Automower Connect API Authentication does not work anymore as they moved to …a new authentication method. (AppKey and AppSecret).
Example of the new API:
`curl -X POST -d "grant_type=client_credentials&client_id=XXX_Application_Key_XXX&client_secret=XXX_Applications_Secret_XXX" https://api.authentication.husqvarnagroup.dev/v1/oauth2/token`
Apparently many/all(?) users are affected: https://community.openhab.org/t/automower-binding-g2/2854/102
## Expected Behavior
The Autower Addon should use the supported authentication method.
## Current Behavior
The Automower Addon does not use a supported authentication method and the connectivity fails and no bridge can be configured successfully.
## Possible Solution
Add a field for App Secret and change the Authentication method.
Working example: `curl -X POST -d "grant_type=client_credentials&client_id=XXX_Application_Key_XXX&client_secret=XXX_Applications_Secret_XXX" https://api.authentication.husqvarnagroup.dev/v1/oauth2/token`
## Steps to Reproduce (for Bugs)
1. Create a new Automower Bridge
2. Use Valid credentials + Valid API Key
3. Bridge does not work and error from Husqvarna API is being logged
> 2022-06-20 22:16:28.815 [ERROR] [oauth2client.internal.OAuthConnector] - grant type password to URL
> https://api.authentication.husqvarnagroup.dev/v1/oauth2/token failed with error code unauthorized_client, description Unauthorized client: `grant_type` is invalid
> 2022-06-20 22:16:28.824 [WARN ] [ternal.bridge.AutomowerBridgeHandler] - Unable to fetch automowers: Rest call failed: statusCode=-1, message=Unable to authenticate
> 2022-06-20 23:16:29.134 [ERROR] [oauth2client.internal.OAuthConnector] - grant type password to URL https://api.authentication.husqvarnagroup.dev/v1/oauth2/token failed with error code unauthorized_client, description Unauthorized client: `grant_type` is invalid
## Your Environment
Using OpenHAB 3.2.0 but also tried the development branch on Github of the openhab-addons (=3.3.0 afaik) with a fresh OpenHAB 3.3.0 installation from the website.
## Notes
I tried to fix it myself but I couldn't get it to work with the OAuth Implementation provided by OpenHAB (the extension uses the built-in OAuth service) as I could not get it to change the grant_type. If there are any pointers how this could be achieved without rolling a new OAuth implementation myself, I'm happy to try to contribute.
I am unsure if the 'old' username/password combination needs to be removed or if it needs to stay there for compatibility reasons.