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

Here is an example that works in Powershell - for those of us using it :P

---------------------------------------------------------------------------------------------------------

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

7 Likes