0
votes

I cannot seem to generate a basic successful call to the onelogin API. I can generate a token from a client ID and secret successfully but every call I do with the token that is output gets a 401. Sample code with replaced token below.

Invoke-RestMethod -Uri https://api.us.onelogin.com/api/2/users? -ContentType application/json -Headers @{Authorization="bearer:12345"} -Method Get

I built the command out by hand to prove it was not some error saving the access_token line out to a variable and still 401.

1
Okay so this seems to be a v2 issue I can submit to v1 just fine but I could really use some of the v2 features - Gabe Whitt

1 Answers

0
votes

It was a space needing to be added in the bearer statement.

$Splat = @{
    Method      = 'GET'
    Uri         = 'https://api.us.onelogin.com/api/2/users?created_until=2020-07-01T20:38:24Z&last_login_until=2020-07-01T20:38:24Z'
    ContentType = "application/json"
    Headers     = @{authorization = "bearer: $($Token)"} 
   
}

Invoke-RestMethod @Splat