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

Awesome, thanks for clearing that up @sander1 .

Hi,
always getting Internal Server Error 500.
Can someone confirm?

@max.reischauer said:
Hi,
always getting Internal Server Error 500.
Can someone confirm?

No One ?

@max.reischauer said:

@max.reischauer said:
Hi,
always getting Internal Server Error 500.
Can someone confirm?

No One ?

It’s very difficult to say anything without knowing what exactly you are doing. Can we see the code you’re using?

@c.blackburn said:
Here is an example using curl from the command line:

curl -X "POST" "https://plex.tv/users/sign_in.json" \
     -H "X-Plex-Version: 1.0.0" \
     -H "X-Plex-Product: YOUR PRODUCT NAME" \
     -H "X-Plex-Client-Identifier: YOUR-PRODUCT-ID" \
     -H "Content-Type: application/x-www-form-urlencoded; charset=utf-8" \
     --data-urlencode "user[password]=YOUR_PASSWORD" \
     --data-urlencode "user[login]=YOUR_USERNAME"

“YOUR PRODUCT NAME” and “YOUR-PRODUCT-ID” can be anything you’d like.

I tried this with both the short password and the full email address and it returned this both times:

{"error":"Invalid email, username, or password."}

Any ideas?

1 Like

Hi,
Sry for the delay:
i’am only using postman to get an token:
here ist what i got:
Thank YOu

no one got the same error?

@max.reischauer said:
no one got the same error?

I can’t replicate. Even with the same tool (Postman) and all the same values I see in your screenshot (and my own login of course) I get a valid and correct response:

/uploads/default/original/3X/2/d/2d852904f344e379e3b8e4c3aef5e24e97699d6b.jpg

Anyone have a good script that will return a token for managed user using the login/password of the owner account? Thanks.

@max.reischauer said:
no one got the same error?

hi Max, I got the same error, and I copy/pasted the info from the webpage, turns out I got a whitespace behind the user[login] 
 you might want to check out that

regards

I’ve linked Sickrage to Plex (placing the token within the Sickrage config) and have been noticing that at some point the Auth token no longer works and when I view it via the wget below, it has changed. I thought the token was static, but seems the token only lasts a few days.

Thanks

token=`/usr/local/bin/wget --quiet
–method POST
–header ‘X-Plex-Client-Identifier: 7608cf36-742b-11e4-8b39-00089bd210a2’
–header ‘X-Plex-Product: Plex Media Server’
–header ‘X-Plex-Version: 3.0’
–header ‘Authorization: Basic xxxxxxxxxxxxxxxxxxxx’
–header ‘Cache-Control: no-cache’
–output-document \

Hi everyone!

I would be much grateful for some help.
All I want to do is get a notification on my (android) phone, when I start watching something. I’m not familiar with any kind of code, although I did get through most of the process with curl (huge thanks to @midwire , for his comment on this).
So I did get the token, the clientidentifier, and I can see that what I created popped up in the Devices section. What I don’t know is, how to get through this part using my knowledge and resources:

Then run the app as follows:

$ TOKEN=api-token PLAYER=client-identifier-to-control node index.js
(from GitHub - plexinc/webhooks-notifications: Use Plex webhooks to display desktop notifications and control playback with media keys)

The idea was, that if i succeed, I will use Tasker or IFTTT somehow, to process the data sent by Plex for a widget I made.

You can also get this Token from the Request Headers in the Browser you’re surfing Plex Media Server on. Can just use that?

@tommyrollo02 That’s the token for the particular Plex Web app you happen to be on, this thread is about getting a unique token for your own app.

Although that token you found would work, it will stop working as soon as the user removes that Plex Web device from their account. You should be using a unique token for your app :wink:.

I’m problem as same as you.
Please, make manual for me.
My email thoatvidiadem@gmail.com

@ccarvell-plex said:
Here is an example that works in Powershell - for those of us using it :stuck_out_tongue:

clear

$url = “https://plex.tv/users/sign_in.xml”

$BB = [System.Text.Encoding]::UTF8.GetBytes(“myplexaccount:mypassword”)

$EncodedPassword = [System.Convert]::ToBase64String($BB)

$headers = @{}

$headers.Add(“Authorization”,“Basic $($EncodedPassword)”) | out-null

$headers.Add(“X-Plex-Client-Identifier”,“TESTSCRIPTV1”) | Out-Null

$headers.Add(“X-Plex-Product”,“Test script”) | Out-Null

$headers.Add(“X-Plex-Version”,“V1”) | Out-Null

[xml]$res = Invoke-RestMethod -Headers:$headers -Method Post -Uri:$url

$token = $res.user.authenticationtoken

Maybe their is a better place to put this, but, this seemed like a good one to store examples to help others along.

Cade

I tried this and it works as far as getting a token but when I try to use it I get an error about it not being authorized. I saw the post about using the user token to get the server token from https://plex.tv/pms/servers.xml but the server token is the same as the token this script returns.

Edit: Never mind. it was a 404 error and it was because I had the wrong section.

1 Like

I also have this issue using curl. Does anyone know why it happens?

Do you use a plex.tv account credentials, since unsure it’ll work with like Google and FB

Thanks for the response.

I usually sign in to Plex using Google sign in, but for this purpose I used my Plex username and password. I even logged out and back into Plex forums, using my username and password to check I had it right.