How to use REST API SAML Auth

How to use REST API SAML Auth

113
Created On 11/10/26 10:55 AM - Last Modified 11/10/26 15:57 PM


Symptom


$response = Invoke-RestMethod "https://{pvwa]/PasswordVault/API/auth/SAML/Logon?concurrentSession=true&apiUse=true&SAMLResponse=$($SamlToken)" -Method 'POST' -Headers $headers -Body $body

Above script call generates the following error: Invoke-RestMethod : 404 - File or directory not found. Server Error  


Environment


11.1;11.2;11.3;11.4;11.5;11.6;11.7;12.0 Privileged Access Manager (PAM, self-hosted) Password Vault Web Access Password Vault Web Access Authentications

Cause


Body parameter should be used as below format in PowerShell script instead:

 

$body = @{

     concurrentSession='true'

     apiUse='true'

     SAMLResponse='PHNhb...'

}

This is not a doc bug according to Idira R&D. The confusion is the body parameter was not exactly same as it was documented, refer to https://docs.microsoft.com/en-us/powershell/module/microsoft.powershell.utility/invoke-restmethod?view=powershell-7 how to load the body parameter in PowerShell.



Resolution


 The Body Parameter format

1) Powershell Script:

===========Begin of the script=============

$url = "https://{PVWA_HOST}}/PasswordVault/api/auth/SAML/logon"

$body = @{

   concurrentSession='true'

   apiUse='true'

   SAMLResponse='PD94b....+'

}

Invoke-RestMethod -Uri $url -Method Post -body $body -ContentType 'application/x-www-form-urlencoded'

 

============End of the script============

2) Postman:Capture.GIF

 



Actions
  • Print
  • Copy Link

    https://knowledgebase.paloaltonetworks.com/KCSArticleDetail?id=kA1hj00000014o0CAA&lang=en_US&refURL=http%3A%2F%2Fknowledgebase.paloaltonetworks.com%2FKCSArticleDetail