Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save darrenjrobinson/e3560ba2d51e5b73124ea5ae18a7db18 to your computer and use it in GitHub Desktop.
Save darrenjrobinson/e3560ba2d51e5b73124ea5ae18a7db18 to your computer and use it in GitHub Desktop.
Get SailPoint IdentityNow oAuth v3 token. Associated Blog Post https://blog.darrenjrobinson.com/using-sailpoint-identitynow-v3-apis-with-powershell/
# IdentityNow Orgname
$Global:orgname = "yourOrg"
# IdentityNow Admin User
$Global:adminUSR = [string]"yourAdminLoginName".ToLower()
$Global:adminPWDClear = 'yourPassword'
# Generate the password hash
# Requires Get-Hash from PowerShell Community Extensions (PSCX) Module
# https://www.powershellgallery.com/packages/Pscx/3.2.2
$Global:passwordHash = Get-Hash -Algorithm SHA256 -StringEncoding utf8 -InputObject ($($adminPWDClear) + (Get-Hash -Algorithm SHA256 -StringEncoding utf8 -InputObject ($adminUSR)).HashString.ToLower())
$Global:adminPWD = $passwordHash.ToString().ToLower()
# SailPoint Supplied ClientID and Secret for your Org
$Global:clientIDv3 = "ba38b166-5f24-4448-ac0b-1234567890"
$Global:clientSecretv3 = "770a71ae20c05301848d2222d8760fe0d9f632383775b315abcdefg1234567899"
# Basic Auth
$Bytesv3 = [System.Text.Encoding]::utf8.GetBytes("$($clientIDv3):$($clientSecretv3)")
$Global:encodedAuthv3 = [Convert]::ToBase64String($Bytesv3)
$Global:Headersv3 = @{Authorization = "Basic $($encodedAuthv3)"}
# Get v3 oAuth Token
# oAuth URI
$Global:oAuthURI = "https://$($Global:orgName).api.identitynow.com/oauth/token"
$Global:v3Token = Invoke-RestMethod -Method Post -Uri "$($Global:oAuthURI)?grant_type=password&username=$($Global:adminUSR)&password=$($Global:adminPWD)" -Headers $Global:Headersv3
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment