ebaauw / homebridge-nb

Homebridge plugin for Nuki Bridge
Apache License 2.0
51 stars 3 forks source link

request 1: error: http status 401 Unauthorized #136

Closed dersimn closed 3 weeks ago

dersimn commented 2 months ago

After pressing the button on the Nuki Bridge I get the following error

request 1: error: http status 401 Unauthorized

Debugging with nb showed that I have to specify -E none to disable Token encryption:

  -E [none|hasedToken|encryptedToken], --encryption=[none|hasedToken|encryptedToken]
  Use encryption method for communication with the Nuki bridge.
  The default is hashedToken.

With
nb -H 10.1.1.106:8080 -T mytoken -E none -D info I get a valid response, but
nb -H 10.1.1.106:8080 -T mytoken -D info shows a similar error that is also shown in Homebridge UI:

nb info: 10.1.1.106:8080: request 1: GET /info
nb info: 10.1.1.106:8080: request 1: GET /info
nb info: warning: 10.1.1.106:8080: request 1: error: http status 401 Unauthorized
nb info: fatal: http status 401 Unauthorized

I found that this is due to homebridge-nbhb-nb-tools/lib/NbClient.js having a fixed encryption that seems to be incompatible with my bridge (idk why I'm the only one here). However changing this manually to none made it work for me: https://github.com/ebaauw/hb-nb-tools/blob/da207d4578877555c853743cc798dcdcd90546e2/lib/NbClient.js#L117

This fix unfortunately doesn't survive an update. Maybe it's possible to make the encryption configurable in homebridge's configuration.json?

ebaauw commented 2 months ago

Did you double-check the clock synchronisation between the server running Homebridge and the Nuki bridge?

dersimn commented 2 months ago

You're right.. it just took like an hour until the bridge got a valid date/time from NTP I guess.

Still any chance to have this configurable?
I usually put all smart home devices into some kind of DMZ with no internet access because I don't trust them, in this case I'd have to switch to none at some point.

ebaauw commented 3 weeks ago

In v1.4.23.