[How To] Request a X-Plex-Token token for your app

That’s the temporary one though, right?

Nope, it works for as long as you keep your server signed in

lol? and if i disconnect the server it’s gone? thats exactly what “temporary” means.

i have no idea how to get this token aswell. And have no interest in reading 82 posts. So please guys … how about a not so nerdy explanation for normal human beings? or, like others said, a simple line in the PMS-Settings !?! Seriously… this is so absolutely not userfriendly

So i ended up right clicking the “database download” on plex/web … there is a token. but is it the temporary one?

1 Like

Normally, you do not sign the server out from plex.tv, so fail to see the problem?

Hey did you ever figure this out? I am in your boat. Extremely confused by what seems to be giberish in the original post. Apparently everyone else seems to understand this perfectly…

Is there a way to get this token at all? This seems way overly complicated for the average person. I have no idea what is being said in the original post and I am completely lost when trying to follow any of the 84 other posts… Scrip[ts and HTTP POST??? what in the world is this? I am trying to get Ombi working and I am tired of the temporary tokens expiring and having to go through that process over and over…

Okay, since dev’s choose the too complex way - and do not respond for an easy solution. okay, to be fair, they never respond to anything :smiley:

here the easy one:

Or plex_autoscan script for token

PLEX_TOKEN - Plex Access Token. This is used for checking Plex’s status, emptying trash, or analyzing media.

  • Run the Plex Token script by Werner Beroux: /opt/plex_autoscan/scripts/plex_token.sh .

wasn’t so hard - or plex (mods/devs)? :joy:
but since you don’t implement such easy way, like ANY other App/Service, i guess you like it rough :wink:
maybe you guys should start thinking “usability”.

3 Likes

Jesus dude. I struggled with this thing for HOURS. Read this and did it, had the token immediately. THANK YOU!!!

Here a shell-script using python3 and command-line input of needed data:

https://gist.github.com/fleXible/709e4583086b926646cb5304361693b4

#!/usr/bin/env python3

import base64
import hashlib
import http.client
import json

username = input('Username: ')
password = input('Password: ')
client_name = input('Client Name: ')
client_version = input('Client Version: ')
client_id = hashlib.sha512('{} {}'.format(client_name, client_version).encode()).hexdigest()
base64string = base64.b64encode('{}:{}'.format(username, password).encode())
headers = {'Authorization': 'Basic {}'.format(base64string.decode('ascii')),
           'X-Plex-Client-Identifier': client_id,
           'X-Plex-Product': client_name,
           'X-Plex-Version': client_version}

conn = http.client.HTTPSConnection('plex.tv')
conn.request('POST', '/users/sign_in.json', '', headers)
response = conn.getresponse()
print(response.status, response.reason)
data = json.loads(response.read().decode())
print('Auth-Token: {}'.format(data['user']['authentication_token']))
conn.close()
1 Like

Python script works great.

I updated the gist to hopefully be a bit more pythonic.

Thanks alot!!

THANK YOU VERY MUCH! This fix it! Shame on Plex because they don’t provide a more user friendly solution

So I followed the instructions in the opening post to get a token. I use this token for node-red-contrib-plex-ws and it does work, but then it suddently stops. Haven’t been able to figure out the timing or why. I can get it back up running if I create a new key and then used that one, but this is not a good solution for me. Last key worked 5 days, this last one only a couple of hours. Any ideas?

I tried all three or four python scripts in here and they all failed with diverse errors. Yes I know how to fix stupid errors like " and ’ that show up when you copy paste.

I have to admit that this is not an easy process for your more than average joe. You really have to know some kind of language to understand whats’ going on here.

I tried this latest script:

#!/usr/bin/env python3

import base64
import hashlib
import http.client
import json

username = input('chezpaul: ')
password = input('mypassword: ')
client_name = input('Client Name: ')
client_version = input('Client Version: ')
client_id = hashlib.sha512('{} {}'.format(client_name, client_version).encode()).hexdigest()
base64string = base64.b64encode('{}:{}'.format(username, password).encode())
headers = {'Authorization': 'Basic {}'.format(base64string.decode('ascii')),
           'X-Plex-Client-Identifier': client_id,
           'X-Plex-Product': client_name,
           'X-Plex-Version': client_version}

conn = http.client.HTTPSConnection('plex.tv')
conn.request('POST', '/users/sign_in.json', '', headers)
response = conn.getresponse()
print(response.status, response.reason)
data = json.loads(response.read().decode())
print('Auth-Token: {}'.format(data['user']['authentication_token']))
conn.close()

And I get this error:
python: can’t open file ‘plex.tv’: [Errno 2] No such file or directory

I know my password but I don’t know my client name and version. Where do I find this?

Thanks for the help

I believe this is whatever you want it to be

post5

what about post 5?

Here’s a one-line command you can run if you have HTTPie installed:

http -f https://plex.tv/users/sign_in.json \
X-Plex-Client-Identifier:some_client X-Plex-Product:Client X-Plex-Version:1.0 \
'user[login]=your_username' 'user[password]=your_password'

What is suggest now in order to support those that use Google or Facebook to log into their Plex Accounts? Is there documents on opening the plex login window and getting a token back from that??