Private/Get-SFAssertion.ps1

function Get-SFAssertion {
    [CmdletBinding()]
    param (
        [Parameter(Mandatory)]
        [string]$BaseUrl,

        [Parameter(Mandatory)]
        [string]$UserId,

        [Parameter(Mandatory)]
        [string]$ClientId,

        [Parameter(Mandatory)]
        [string]$TokenEndpointUrl,

        [Parameter(Mandatory)]
        [string]$PrivateKey
    )

    $uri = "$BaseUrl/oauth/idp"
    $headers = @{ 'Content-Type' = 'application/x-www-form-urlencoded' }
    $body = @{
        user_id     = $UserId
        client_id   = $ClientId
        token_url   = $TokenEndpointUrl
        private_key = $PrivateKey
    }

    try {
        return Invoke-RestMethod -Method Post -Uri $uri -Headers $headers -Body $body
    }
    catch {
        throw "Failed to obtain SuccessFactors assertion from '$uri': $($_.Exception.Message)"
    }
}