Created
September 15, 2017 21:28
-
-
Save matt2005/021f22eb10514091d37715d6a7cc6f06 to your computer and use it in GitHub Desktop.
Plex x-token
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$Credential=Get-Credential -Message 'Plex Credentials' | |
$url = "https://plex.tv/users/sign_in.xml" | |
$BB = [System.Text.Encoding]::UTF8.GetBytes($('{0}:{1}' -f $Credential.GetNetworkCredential().Username,$Credential.GetNetworkCredential().Password)) | |
$EncodedPassword = [System.Convert]::ToBase64String($BB) | |
$headers = @{} | |
$headers.Add("Authorization","Basic $($EncodedPassword)") | out-null | |
$headers.Add("X-Plex-Client-Identifier","HASS") | Out-Null | |
$headers.Add("X-Plex-Product","Home Assistant") | Out-Null | |
$headers.Add("X-Plex-Version","V1") | Out-Null | |
[xml]$res = Invoke-RestMethod -Headers:$headers -Method Post -Uri:$url | |
$token = $res.user.authenticationtoken | |
Return $token |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment