Flow Designer - Powershell step - dealing with credentials

Jeffreys Quinti
Tera Contributor

Hi all,

I'm currently configuring an Action within a subflow that calls an API to close an event. To do so I'm using the midserver and the powershell step so I can call the API from the midserver.

The script for now uses a hardcoded basic Auth in the header of the GET request like so : 
$GETheaders.Add("Authorization", "Basic XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX")

Try{
    [System.Xml.XmlDocument]$GETResponse = (Invoke-RestMethod $WebServer -Method 'GET' -SessionVariable WebSession -Headers $GETheaders)
} Catch {
    Add-Content $logfile -Value "$((Get-Date).ToString("yyyy-MM-dd HH:mm:ss")) [ERROR] $($GETResponse.event.Id) - $_" 
    Throw $_
}

How can I safely store my Basic Auth token without having to hardcode it directly in the script? What's the best practice? 

Best regards,
Jeff

1 ACCEPTED SOLUTION

Richard Hine
Tera Guru
Tera Guru

Jeffreys,

I am not sure of the use case, but why wouldn't you just have a REST step in your action to make the call for you and set the step to use the MID server? Then you can use the supported Connection and Credential alias to populate the credentials.

Avoids you needing to do any powershell scripting and keeps you to an SN supported way of doing things without creating technical debt?

Thanks,

Richard

View solution in original post

1 REPLY 1

Richard Hine
Tera Guru
Tera Guru

Jeffreys,

I am not sure of the use case, but why wouldn't you just have a REST step in your action to make the call for you and set the step to use the MID server? Then you can use the supported Connection and Credential alias to populate the credentials.

Avoids you needing to do any powershell scripting and keeps you to an SN supported way of doing things without creating technical debt?

Thanks,

Richard