Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Calling SailPoint IdentityNow Private API;s (v1)
# Your API Client ID
$clientID = 'yourClientID'
# Your API Client Secret
$clientSecret = 'yourClientSecret'
$Bytes = [System.Text.Encoding]::utf8.GetBytes("$($clientID):$($clientSecret)")
$encodedAuth = [Convert]::ToBase64String($Bytes)
# Your IdentityNow Tenant Name
$orgName = 'yourOrgName'
# IdentityNow Admin User and PWD to connect with via oAuth
$adminUSR = [string]"AdminUser1".ToLower()
$adminPWDClear = 'SuperStrongP@$$W0rdNOT!'
# Encrypt creds from above
$passwordHash = Get-Hash -Algorithm SHA256 -StringEncoding utf8 -InputObject ($($adminPWDClear) + (Get-Hash -Algorithm SHA256 -StringEncoding utf8 -InputObject ($adminUSR)).HashString.ToLower())
$adminPWD = $passwordHash.ToString().ToLower()
# Base URI for Private API's (v1 APIs)
$baseURI = "https://$($orgName).identitynow.com"
# URI to get Token
$tokenURI = "https://$($orgName).identitynow.com/api/oauth/token?grant_type=password&username=$($adminUSR)&password=$($adminPWD)"
# Get Token
$token = Invoke-RestMethod -Method POST -Uri $tokenURI -Headers @{Authorization = "Basic $($encodedAuth)" }
if ($token ) {
try {
# Private API Profile List
$profiles = Invoke-RestMethod -Method GET -Uri "$($baseURI)/api/profile/list" -Headers @{Authorization = "Bearer $($token.access_token)"}
$profiles
}
catch {
write-host -foregroundcolor yellow "Well, that didn't work. Are you calling the correct API?"
}
}
else {
write-host -foregroundcolor yellow "Well, that didn't work. Check your credentials, update and try again."
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.
You signed in with another tab or window. Reload to refresh your session. You signed out in another tab or window. Reload to refresh your session.