Sholofly / lghorizon-python

Api for controlling LG Horizon settop boxes
MIT License
1 stars 7 forks source link

Virgin Media GB authentication #14

Closed caraar12345 closed 1 year ago

caraar12345 commented 1 year ago

Moving this over from https://github.com/Sholofly/lghorizon/issues/7#issuecomment-1359655881 as it might well be a separate issue - and it's to do with the underlying library rather than the HA integration.

So I've had a bit of a deep dive on Virgin GB with Burp to try and watch how it authenticates. And it seems the method by which to get the MQTT token is entirely different to the rest (obviously...!).

In looking further, it seems there are some issues around the auth actually being completed (PR incoming soon!).

However, I've reached a bit of a weird point in which LGHorizonAuth.fill(auth_json) is just... not working fully?

Seems as though the datetime.fromtimestamp isn't working -- but there's no reason as to why it wouldn't as it works fine in a Python REPL console.

    def fill(self, auth_json)-> None:
        print(auth_json)
        print("hhID " + auth_json["householdId"])
        print("access " + auth_json["accessToken"])
        print("refresh " + auth_json["refreshToken"])
        print(int(auth_json["refreshTokenExpiry"]//1000.0))
        print("un "+ auth_json["username"])
        print("refresh exp "+ datetime.fromtimestamp(auth_json["refreshTokenExpiry"]//1000.0))
        self.householdId = auth_json["householdId"]
        self.accessToken = auth_json["accessToken"]
        self.refreshToken = auth_json["refreshToken"]
        self.username = auth_json["username"]
        self.refreshTokenExpiry = datetime.fromtimestamp(auth_json["refreshTokenExpiry"]//1000.0)
caraar12345 commented 1 year ago

Unfortunately, I've hit an impasse in that I've managed to hit the maximum concurrent session limit... and I cannot find a way to reset that D:

Sholofly commented 1 year ago

A Massive thank you for trying to fix it. It's very much appreciated. I've added a minor comment. All other change are ok as far as I can see. Maybe you can take a look at this code: It uses the same process but in an other language: https://github.com/jsiegenthaler/homebridge-eosstb/blob/master/index.js#L1020

dnwlmz commented 1 year ago

@Sholofly Just confirming that I've been able to test and this is now working and controlling my boxes; THANK YOU SO MUCH! Just noted that some of the channel switching is a bit slow, but I suspect that this may be down to all the paths that the command needs to take

Sholofly commented 1 year ago

@dnwlmz Good to hear its working for you. Just curious, can you define a bit slow in this case?