Closed dtpanic closed 2 years ago
That is not an error that I have encountered previously, and it is not listed in the Home Connect API documentation.
Testing just now with a new ClientID I do not get that error:
[04/05/2022, 05:57:34] [HomeConnect] No saved authorisation data found
[04/05/2022, 05:57:34] [HomeConnect] Requesting Home Connect authorisation using the Device Flow
[04/05/2022, 05:57:34] [HomeConnect] Home Connect request #1: POST https://api.home-connect.com/security/oauth/device_authorization
[04/05/2022, 05:57:35] [HomeConnect] Home Connect request #1: OK +387ms
[04/05/2022, 05:57:35] [HomeConnect] Home Connect authorisation required. Please visit:
[04/05/2022, 05:57:35] [HomeConnect] https://api.home-connect.com/security/oauth/device_verify?user_code=XXXX-XXXX
[04/05/2022, 05:57:35] [HomeConnect] Waiting for completion of Home Connect authorisation (poll every 5 seconds, device code XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX expires after 600 seconds)...
However, if I deliberately specify an invalid value for clientid
in the config.json
file then the Home Connect API does return the missing or invalid request parameters [invalid_request]
error that you are seeing.
Hence, the problem is almost certainly due to you not correctly setting clientid
to the ClientID, e.g. including additional text in the value, or missing some digits. The value should be exactly 64 hexadecimal digits (0
-9
or A
-F
) surrounded by quotes.
can confirm Home Connect API error: invalid content type [invalid_request]
some investigation - maybe related?
when visiting https://developer.home-connect.com/applications per default there is a "API Web Client" Application. Below is a web based API client to play around. Before playing around one has to authorise (obviously). However, when I "select all" and try to authorize get the error:
auth Error[invalid_scope]: given+scope+doesn't+match+requested+scope.
When I try to authorise just e.g. IdentifyAppliance
it works.
Maybe the auth-scope is somehow the issue?
Testing just now with a new ClientID I do not get that error:
did you remove var/lib/homebridge/.homebridge-homeconnect-v1.schema.json
before testing?
further playing around: the following authorisations throw:
Images
Grants access to read resources under /api/homeappliances/{haId}/images
FridgeFreezer-Images
Grants access to read resources under /api/homeappliances/{haId}/images on fridgefreezers
FridgeFreezer
Grants access to read or modify all resources under /api/homeappliances on fridgefreezers
Refigerator-Monitor
Grants access to read resources under /api/homeappliances except images and settings on refrigerators
Refigerator-Control
Grants access to modify resources under under /api/homeappliances except images and settings on refrigerators
Refigerator-Settings
Grants access to read and modify resources under /api/homeappliances/{haId}/settings on refrigerators
Refigerator
Grants access to read or modify all resources under /api/homeappliances on refrigerators
I will quickly write an email to home connect
@Jacubeit ...
can confirm Home Connect API error: invalid content type [invalid_request]
Are you saying that you are seeing the same error using this plugin? Is this the first time you have attempted to use the plugin?
I have tried again, and with the ClientID correctly added to config.json
I still do not see that error. Even using an invalid ClientID but using the correct format (64 hexadecimal digits) does not give that error. Only by configuring something that does not resemble a ClientID triggers that error.
when visiting https://developer.home-connect.com/applications per default there is a "API Web Client" Application
You can use that ClientID with this plugin by also setting the following in config.json
:
"simulator": true
This allows use of the simulated appliances at https://developer.home-connect.com/simulator for testing.
That ClientID will not work with this plugin when using your own appliances, i.e. without "simulator": true
.
Maybe the auth-scope is somehow the issue?
No. That is not the issue.
The scopes requested by this plugin can be found here: https://github.com/thoukydides/homebridge-homeconnect/blob/005662a214587968cd65d72af3664cc4bd5079e2/lib/homeconnect_api.js#L23
Even if unsuitable scopes were requested, that would only be discovered after authentication is attempted, and it is not getting that far.
If you look at the Home Connect documentation you will see that some scopes require an Additional Partner Agreement. This applies to *-Images
, Images
, and FridgeFreezer
. This plugin does not request any of those scopes.
did you remove var/lib/homebridge/.homebridge-homeconnect-v1.schema.json before testing?
That file is completely irrelevant. It is only used by homebridge-config-ui-x, and would not affect this error.
I will quickly write an email to home connect
As far as I can see the Home Connect API is working correctly. In your test you are requesting scopes that require an Additional Partner Agreement and the API is correctly rejecting them.
thank you for the answer. I have used the plugin back at the time when you published it. Ir worked fine.
I switched off my homebridge pi for about 1-2 years - reactivated it yesterday and encountered the error mentioned above.
Hi,
Also getting this error on a new install. The logs show:
[04/05/2022, 09:47:53] [HomeConnect] Home Connect API error: invalid content type [invalid_request]
I have double checked the client ID is the same:
I still cannot reproduce this error myself (with a valid and correctly configured ClientID) but have reported it to the Home Connect Developer team.
From my testing it seems like the device_authorization endpoint must have a Content-Type header flag set to application/x-www-form-urlencoded or else it will return an invalid content type error.
I am still unable to reproduce this error. However, from the Home Connect API documentation a Content-Type: application/x-www-form-urlencoded
header is required (confirmed by Home Connect Developer support via email). I have added this in v0.24.2.
Hopefully this fixes the issue. However, since it works for me without this header I cannot verify the fix myself...
Nice one, it is working well. Many thanks
for me, unfortunately, it did not fix it.
I setup a clean Pi with new homebridge and only this plugin. Also I tried to setup a new developer account.
when using a new application in the developer portal with setting simulator:false
in homebridge:
[04/05/2022, 22:03:42] Homebridge v1.4.1 (HAP v0.10.2) (Homebridge 66C4) is running on port 51022.
[04/05/2022, 22:03:42] [HomeConnect] No saved authorisation data found
[04/05/2022, 22:03:42] [HomeConnect] Requesting Home Connect authorisation using the Device Flow
[04/05/2022, 22:03:42] [HomeConnect] Home Connect request #1: POST https://api.home-connect.com/security/oauth/device_authorization
[04/05/2022, 22:03:42] [HomeConnect] Failed to read the current configuration schema: ENOENT: no such file or directory, open '/var/lib/homebridge/.homebridge-homeconnect-v1.schema.json'
[04/05/2022, 22:03:43] [HomeConnect] Home Connect request #1: invalid content type [invalid_request] +698ms
[04/05/2022, 22:03:43] [HomeConnect] Home Connect API error: invalid content type [invalid_request]
[04/05/2022, 22:03:43] [HomeConnect] Retrying client authentication in 60 seconds
(node:18962) ExperimentalWarning: buffer.Blob is an experimental feature. This feature could change at any time
(Use `node --trace-warnings ...` to show where the warning was created)
when using the "API WebClient credentials" with setting simulator:true
:
[04/05/2022, 22:01:32] Homebridge v1.4.1 (HAP v0.10.2) (Homebridge 66C4) is running on port 51022.
[04/05/2022, 22:01:32] [HomeConnect] No saved authorisation data found
[04/05/2022, 22:01:32] [HomeConnect] Attempting to short-circuit authorisation Code Grant Flow for the Home Connect appliance simulator
[04/05/2022, 22:01:32] [HomeConnect] Home Connect request #1: GET https://simulator.home-connect.com/security/oauth/authorize
[04/05/2022, 22:01:32] [HomeConnect] Failed to read the current configuration schema: ENOENT: no such file or directory, open '/var/lib/homebridge/.homebridge-homeconnect-v1.schema.json'
[04/05/2022, 22:01:33] [HomeConnect] Home Connect request #1: Redirect https://apiclient.home-connect.com/o2c.html?code=[LONGCODE] +808ms
[04/05/2022, 22:01:33] [HomeConnect] Using authorisation code [LONGCODE]== and redirect https://apiclient.home-connect.com/o2c.html to request token
[04/05/2022, 22:01:33] [HomeConnect] Home Connect request #2: POST https://simulator.home-connect.com/security/oauth/token
[04/05/2022, 22:01:33] [HomeConnect] Home Connect request #2: Invalid request: content must be application/x-www-form-urlencoded [invalid_request] +105ms
[04/05/2022, 22:01:33] [HomeConnect] Home Connect API error: Invalid request: content must be application/x-www-form-urlencoded [invalid_request]
[04/05/2022, 22:01:33] [HomeConnect] Retrying client authentication in 60 seconds
(node:17606) ExperimentalWarning: buffer.Blob is an experimental feature. This feature could change at any time
(Use `node --trace-warnings ...` to show where the warning was created)
I went through the Device Flow
with the Postman Rest Client on a Mac.
It worked perfectly and I can access all my production devices.
Any idea what I can do to get the plugin working?
Have the same issue Invalid content type / invalid request
I tried again with the latest version (0.24.2) and unfortunately still get the same error:
[04/05/2022, 22:20:26] [HomeConnect] Home Connect API error: invalid content type [invalid_request] [04/05/2022, 22:20:26] [HomeConnect] Retrying client authentication in 60 seconds
@thoukydides if it helps I could temporary provide credentials to my home connect and dev account.
It looks like the handling of fetch headers was changed between undici@5.0.0 and undici@5.1.0.
v0.24.3 should now work with the latest version of undici.
@thoukydides it works for me thank you very much for your work!
Your a home connect hero ❤️ Works!
Fixed the issue for me too - thank you!
On May 5, 2022, at 8:39 AM, floriangrotz @.***> wrote:
Your a home connect hero ❤️ Works!
— Reply to this email directly, view it on GitHub https://github.com/thoukydides/homebridge-homeconnect/issues/86#issuecomment-1118498247, or unsubscribe https://github.com/notifications/unsubscribe-auth/AZAELIU2EOLJBU7X3KCP3ODVIO6PXANCNFSM5VAQAKFQ. You are receiving this because you authored the thread.
Description of Issue
I am setting up the HomeConnect plugin. I copied the config.json as instructed, and added the ClientID that I set up for my application via the HomeConnect developer website.
When I run Homebridge (and look in the logs for the URL to authorize the app), I instead get the following error:
Home Connect API error: invalid content type [invalid_request]
Plugin Version
homebridge-homeconnect v0.24.1
Logs:
[03/05/2022, 20:45:17] [HomeConnect] No saved authorisation data found [03/05/2022, 20:45:17] [HomeConnect] Requesting Home Connect authorisation using the Device Flow [03/05/2022, 20:45:18] [HomeConnect] Home Connect API error: invalid content type [invalid_request] [03/05/2022, 20:45:18] [HomeConnect] Retrying client authentication in 60 seconds (node:5225) ExperimentalWarning: buffer.Blob is an experimental feature. This feature could change at any time (Use
node --trace-warnings ...
to show where the warning was created)