If I try to use basic auth, like all the examples found on the net, I get a 401 unauthorized error, which makes sense.
I cannot find a single example on how to do auth with SSO, so I am stumbling around trying to create the correct headers based on this page:
https://www.ibm.com/docs/en/planning-an ... g-sessions
So my code looks something like this:
Code: Select all
$base64AuthInfo = [Convert]::ToBase64String([Text.Encoding]::ASCII.GetBytes("username:password:namespace"))
$headers = New-Object "System.Collections.Generic.Dictionary[[String],[String]]"
$headers.Add('WWW-Authenticate',("CAMPassport https://server1:443/ibmcognos/bi/v1/disp, CAMNamespace" ))
$headers.Add('Authorization',("CAMNamespace base64($base64AuthInfo)") )
$headers.Add('Accept','application/json')
$uri = "https://server2:12345/api/v1/activesession"
[Net.ServicePointManager]::SecurityProtocol = "tls12, tls11, tls"
Invoke-RestMethod -Headers $headers -Method get -Uri $uri