-
-
Save freeload101/fe2e7ce5247bbed6676a74487f98a66d 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