Load Token issue in Powershell script

Hi There,

I am not able to load token from my powershell script. I have encrypted the secret using securestring. Seeing following error in powershell script logs “(04-30-2025 13:31:47) [ERROR] Failed to obtain identity: Exception calling “.ctor” with “2” argument(s): “Cannot process argument because the value of argument “password” is null. Change the value of argument “password” to a non-null value.”
(04-30-2025 13:31:47) [ERROR] Failed to obtain identity. Terminating after script before actions taken.”

Error in IQ Trace logs – “04/30/2025 12:52:37 : RpcHandler [ Thread-5 ] ERROR : “Malformed request received from client - ::ffff:168.63.129.16:61164. Received header length as - Error in parsing - Input string was not in a correct format.”

This is my Load token function - function Load-Token () {
# This method is used to load the environment variables for the SailPoint SDK.
# ConvertFrom-SecureString -SecureString $(Read-Host -AsSecureString)

$env:SAIL_BASE_URL="https://$SAILPOINT_TENANT.api.identitynow.com"
$env:SAIL_CLIENT_ID=$SAILPOINT_CLIENT_ID
    
$credentials = New-Object -TypeName System.Management.Automation.PSCredential -ArgumentList $SAILPOINT_CLIENT_ID, ($SAILPOINT_ENCRYPTED_CLIENT_SECRET | ConvertTo-SecureString) 
$env:SAIL_CLIENT_SECRET=$credentials.GetNetworkCredential().password

}
Could someone help me on this?

I think you need to convert Client secret from secure string to plain text.

$ClientSecret = Convert-SecureStringToPlainText -secureString $SecureClientSecret
1 Like

This is resolved - Password needs to be encrypted with the service account.