8none1 / bravialib

Python 2 library for talking to some Sony Bravia TVs
GNU General Public License v3.0
15 stars 7 forks source link

auth cookie expiration is unhandled #1

Open 8none1 opened 7 years ago

8none1 commented 7 years ago

Currently (it seems) that the auth cookie expires and then this library stops working.

farhanito commented 7 years ago

what if we use Pre-shared Key as authentication method like mentioned here?

we just need to add X-AUTH-PSK: [PSK] to the Header of each POST request

8none1 commented 7 years ago

That seems like a good idea. I've push a couple of quick changes which I think will work, but I haven't tested it properly, so there are likely to be broken things here and there. Feel free to see how you get on with it.

Once you've created the Bravia object (e.g. tv = bravialib.Bravia(.....)) you should set the x_auth_psk key like this... tv.x_auth_psk = "foobar"

and then it should use that instead of the cookie.

8none1 commented 7 years ago

That all said - I would prefer to use the cookie method because it requires less work on the part of the user (i.e run the script, get prompted, enter the PIN, done vs go in to the menus on the telly and set a PSK).

I think all that's needed is to run the "connect" method again to get a new cookie, I just haven't bothered to test it.

The main driver for this project was to hook the TV up to Alexa, but I found that trying to control the TV with Alexa was painful, annoying and slow - so basically gave up.