1
votes

I am trying to integreate with OneLogin SSO, and in our app we have a system of enabling / disabling users. We would like to set that status also on OneLogin so user cannot log in there either after his account has been disabled.

The only thing is - i can't find a proper API endpoint to do this. When im doing it on admin panel (flip user 'active' switch) and save it, then call users API, i get

GET https://api.us.onelogin.com/api/1/users

Response:

{   
    ...
    'status': 2,
    ... 
}

From documentation i read 1 is active, 2 is suspended, which is fine. Status is the only thing that changes (in API get users result) when i flip the switch on admin. It does exatly what i need - disables user ability to log in.

The problem is that I Cannot set it through API:

PUT https://api.us.onelogin.com/api/1/users/XXXXXX

request body:

{"status": 2}

response:

{
  "status": {
    "error": true,
    "code": 400,
    "type": "bad request",
    "message": {
      "description": "status is an excluded attribute for put request for user",
      "attribute": "status"
    }
  }
}

Im using API version 1, documentation i relied on: https://developers.onelogin.com/api-docs/1/users/user-resource

So the question is: which endpoint do i use to disable / enable user account or change this status? Can it be achieved through API?

1

1 Answers

1
votes

I figured it out. When you go on users -> mappings, you can create an action mapping (if you set a particular field through API, defined action will happen). Just set a built-in field that you're not using, in my case i use 'title', and set action to set the status: I use title, you can select any additional field

Then create a simmilar rule, to deactivate user. After all, click 'Reapply all mappings' on mappings screen and thats it. On any further API request, if this field will change, according event will fire.