Requesting a new Plex Auth token for from the CLI

For those interested, I wanted to setup my system to have it’s own Plex Auth token (and not just borrow the Auth token of another browser or device). I figured out a Python3 script, based on an old script by svdlugt that you can run on the CLI that will register your system as a separate device and generate a new Auth token that you can use in your Plex integration.

Note that to run this script, you will need to make sure Python3 is available for the CLI with the following command:

`apk add --no-cache python3`

Here is my sample script, which I named “” and made executable on the CLI. Update with your Plex credentials and capture the output to find your shiny new Auth token.

import http.client, urllib.request, urllib.parse, urllib.error, base64
username = "myplexusername"
password = "mysupersecretpassword"

string = '%s:%s' % (username, password)
base64string = base64.standard_b64encode(string.encode('utf-8'))

txdata = ""

headers={'Authorization': "Basic %s" % base64string.decode('utf-8'),
'X-Plex-Client-Identifier': "Hassio",
'X-Plex-Product': " System Monitor",
'X-Plex-Version': "0.001"}
conn = http.client.HTTPSConnection('')

response = conn.getresponse()

print(response.status, response.reason)

data =



1 Like