With the PowerShell SDK, how do I switch between different clientid/secret or access tokens for different v2024 cmdlets?

With the use of External Triggers in Workflows, they seem to require trigger-specific client/id/secret to kickoff the workflow.

When I have a PowerShell script, using a tenant-level PAT, how do I switch to another access token for a specific cmdlet (New-V2024ExternalExecuteWorkflow)?

(…because I’m see an “Unauthorized” error when using an all scope PAT)

I think you need to change the $env variables:

$env:SAIL_BASE_URL='https://[yourTenantHere].api.identitynow.com'
$env:SAIL_CLIENT_ID='[yourClientID]'
$env:SAIL_CLIENT_SECRET='[yourClientSecret]'

Then you can switch it back to the tenant PAT after you run the command you need

Try that and let me know if it helps

Nice. That did the trick. Looks like the environment variables take priority if they exist, above the configuration specified in environment config file.

So it was like so:

Get-Transforms                             # Using environment config file
$env:SAIL_BASE_URL='https://[yourTenantHere].api.identitynow.com'
$env:SAIL_CLIENT_ID='[yourClientID]'
$env:SAIL_CLIENT_SECRET='[yourClientSecret]'
New-V2024ExternalExecuteWorkflow -id xxxxx # Using env vars
Remove-Item -Path Env:SAIL_*               # Wiping env vars
Get-Transforms                             # Using environment config file again

Awesome, I’m glad it worked out!