Skip to content

Commit

Permalink
Fix auth on PS5.1
Browse files Browse the repository at this point in the history
  • Loading branch information
RobFaie authored Jan 19, 2022
1 parent bb0763d commit 2fca64f
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions functions/Invoke-Method.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -155,11 +155,11 @@ function Invoke-Method {
$params.Authentication = 'Basic'
} else {
# PS Desktop requires manual header creation. Basic auth is only supported by challenge.
$raw = '{0}/token:{1}' -f $Context.Credential.username, $Context.Credential.GetNetworkCredential().password
$bytes = [System.Text.Encoding]::Unicode.GetBytes($raw)
$raw = '{0}:{1}' -f $Context.Credential.GetNetworkCredential().username, $Context.Credential.GetNetworkCredential().password
$bytes = [System.Text.Encoding]::ASCII.GetBytes($raw)
$encoded = [Convert]::ToBase64String($bytes)

$params.Headers.Authentication = "basic: $encoded"
$params.Headers.Authorization = "Basic $encoded"
}

if ($PSBoundParameters.ContainsKey('Body')) {
Expand Down

0 comments on commit 2fca64f

Please sign in to comment.