michielpost / Q42.HueApi

C# helper library to talk to the Philips Hue bridge
MIT License
411 stars 114 forks source link

Read config with non-whitelisted user #126

Closed remartens closed 6 years ago

remartens commented 6 years ago

According to the Hue bridge discovery documentation you can also retrieve the config of a bridge without being whitelisted.

Another option is to read the configuration information from the bridge by using a RESTful request. It is not necessary to authenticate the application with the bridge. This can be executed by sending a GET request to http://<bridge ip address>/api/<username>/config

username can be kept empty or a name which is not yet whitelisted.

I tested this and it works indeed, but with the Q42.HueApi library a null reference exception is thrown, because it expects the WhiteList property to be filled. When you use a non-whitelisted user, this property does not exist hence will be null and you get the null reference exception.

It would be nice to be able to read the config before registration, so you can show more info to the user for located bridges. Then it will be easier for the user to pick one (based on the name) for registration.

michielpost commented 6 years ago

Thanks, great find. I've fixed it and you can now get the bridge config without an API key. It's in the latest version on NuGet (3.5.2)