lukasroegner / homebridge-philips-hue-sync-box

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

Script to get auth token #59

Closed katzenbaer closed 2 years ago

katzenbaer commented 2 years ago

I was reading that the timing of when you send the POST request is important, so I wrote a quick Python script that loops the request until it gets back a 200 status code. It made it super easy to get the auth code.

import logging
import requests
import time

while True:
    r = requests.post('https://YOUR.IP.ADDRESS.HERE/api/v1/registrations',
                      json={
                          "appName": "homebridge",
                          "appSecret": "MDAwMTExMDAwMTExMDAwMTExMDAwMTExMDAwMTExMDA=",
                          "instanceName": "homebridge"
                      }, verify=False)
    print(r.status_code, r.json())
    if r.status_code == 200:
        break
    time.sleep(0.1)

print("Done")
katzenbaer commented 2 years ago

Closing to not clutter issues tab, but leaving it here for reference.