myplex authentication help/examples?

python
Guys,

Does anyone have a working example of how to authenticate against the myplex API in python?

I've tried a number of different ways, but keep getting back a HTTP error code of 422 (Unprocessable Entity). I'm mainly using urllib2, but also tried httplib without success.

I'm attempting a POST against https://my.plexapp.com/users/sign_in.xml using basic Authentication with my working userid/password.

Thanks

Got it, didn’t realise that you have to send the Plex client header as part of the initial request:



<br />
import urllib2<br />
import base64<br />
<br />
username = "bingo"<br />
password = "fatpants"<br />
<br />
request = urllib2.Request("https://my.plexapp.com/users/sign_in.xml","")<br />
base64string = base64.encodestring('%s:%s' % (username, password)).replace('
', '')<br />
request.add_header("Authorization", "Basic %s" % base64string)<br />
request.add_header("X-Plex-Client-Identifier", "sausages")<br />
result = urllib2.urlopen(request)<br />
print result.read()<br />


You beat me to it :slight_smile:

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.