lwsrbrts / PoSHue

Windows PowerShell 5/PowerShell Core 6 Classes for controlling Philips Hue Bridge and Hue Lights, Groups, Sensors.
GNU Lesser General Public License v3.0
51 stars 7 forks source link

Remote API #3

Closed laaneric closed 6 years ago

laaneric commented 8 years ago

Have you thought about adding support for the Remote API?

lwsrbrts commented 8 years ago

Hi laaneric, thanks for your interest! I haven't actually looked in to the Remote API yet - it's a "by request" access API "available to a few select partners" but it's definitely something on my radar as I can imagine the level of control this might bring if scripts can be executed "off the LAN". My focus more recently has been purely on getting a decent working example of the Lights API with enough control to make the project useful to people other than me.

I'll probably move on to the other next most useful APIs (Groups, Schedules, Scenes) before Remote but, depending on the level of continued interest, I'll bump it up the list!

Again, thanks for your interest :+1:

Lewis

lwsrbrts commented 7 years ago

As per Philips' process, I emailed them months ago but I've had nothing at all back from them so I can only assume they have no interest inallowing me access to the API.

lwsrbrts commented 6 years ago

Looks like Philips finally woke up. From what I can gather, their remote API is now generally accessible so I have requested to create an "app" with them. Once that is approved and I have my OAuth2 Client ID and Client Secrets, I can start working on how to deliver integration via PowerShell.

Unfortunately, given that their Remote API is designed for Web based applications, they don't offer - as far as I can tell - any method of authenticating and verifying tokens without use of the Client Secret and, as a result, I'm likely to have to force users over to a browser for authentication/access and token generation in order to obtain said tokens. It's not ideal but the alternative is making the client secret...err, not a secret, which means anybody could use it.

Flow is, I think, like this but subject to change depending on what I discover during implementation.

  1. Create a [HueBridge] object or use a static method called something like EnableRemoteAccess.
  2. Return a URL that the user must paste in to the browser.
  3. User visits URL and is requested by the remote API to authorise access to their Hue system.
  4. User is bounced back to my website (https://www.lewisroberts.com) with some additional information from the API.
  5. My website does some server-to-server processing in the background, using the secret in a secret way.
  6. User receives a list or JSON of their access and refresh tokens which they store in a file or download.
  7. User runs another method to import the access and refresh tokens.
  8. A new constructor would likely have to be written to import the tokens and deal with using the remote API instead of going to their local bridge IP.

Lots of detail to work out obviously but that sounds like the process, for now.

Users can delete PoSHue's access to their bridge using the Hue Account website: https://account.meethue.com/apps

lwsrbrts commented 6 years ago

Now pushed to the gallery 2.0.1 supporting the Hue Remote API.