lukasroegner / homebridge-philips-hue-sync-box

Homebridge plugin for the Philips Hue Sync Box.
MIT License
55 stars 12 forks source link

{"code": 2, "message": "Invalid Token"} #48

Closed j-ktz closed 2 years ago

j-ktz commented 3 years ago

Trying to the first step of visiting https:///api/v1/registrations in a browser, and get the following error message:

{"code": 2, "message": "Invalid Token"}

Sync Box is on and not syncing at the moment. Any ideas?

luigi-lauro commented 3 years ago

Hi, trying to help since I see the author isn't active recently. The documentation is a bit barebone, but explains how to do it. It's not enough to just visit that URL in a browser, you have to make a POST request with a specific JSON payload in the request. For doing that you will need a command-line tool, like CURL in unix shells.

What I did was: curl --insecure -d "{ \"appName\": \"homebridge\", \"appSecret\": \"MDAwMTExMDAwMTExMDAwMTExMDAwMTExMDAwMTExMDA=\", \"instanceName\": \"homebridge\" }" https://192.168.4.30/api/v1/registrations

This worked perfectly, it gave the first time the invalid state, then after I was able to press and release the button on the box fast enough to make it stay WHITE and not go red (it took 5+ tries, it's too fast to wait for it to do it and then react, you have to preemptively "guess" the timing with a few tries), and then I did the same command again and got the accessToken string to put in the plugin configuration in Homebridge config UI.

Hope it's helpful to solve and make it work. Once you do that, the plugin works perfectly and it's fast and reliable.

luigi-lauro commented 3 years ago

Did you make it work in the end?

antoniovmo commented 3 years ago

I already got my access token, but after that I really don't know where to put the following settings, please help!

clemone210 commented 2 years ago

I got the same issue. The reason for this is that if you open the URL in your browser it's a GET curl. You need to use POST. You can use postman to do this. The body of the POST needs to be like described. This gets me the right way, but unfortunately, I don't get the access token.

image

djchad72 commented 2 years ago

@clemone210 What I had to do was screen share to my computer from my tablet so I could sit right next to the Sync Box. For me I would hold down the button on the Sync Box, it would turn green, but it would also turn to red vs white (as described in the instructions. So what I did was hold until it turned green with left hand, and right hand was ready to click on the SEND in Postman as soon as I saw Green LED. It took a couple tries, but that caused 1 request to work and give me the token.

lukasroegner commented 2 years ago

I've enhanced the README with a detailed explanation on how to use Postman to retrieve an access token.