- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-04-2022 11:01 AM
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
Solved! Go to Solution.
- Labels:
-
Event Management

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-06-2022 01:48 AM
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

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-06-2022 01:48 AM
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