Update Users Assigned to an Application via API

Hello,

I’m looking to update a set of our applications to a default group of users on a regular cadence - our business need is to grant folks access to an app and then remove that access after x number of days.

I would like to do this programmatically via the API - in the App response body from https:/{{url}}/api/v1/apps/{{appID}} - I see a user href - in Node JS, ( using Axios) its here - response.data._links.users.href

I’m wondering if that is the user list associated with the application and if it would accept a PUT request. Our use case is to simply revert access back to a predefined list of admin users at a regular cadence.

I’m thinking I could have a preset JSON object containing only the users who need the app by default and PUT that JSON on that https://{{domain}}.okta.com/api/v1/apps/{{id}}/users endpoint.

Any help would be greatly appreciated! if this doesn’t work, any advice would also be greatly appreciated!

So why exactly app assignment API does not work for you?

Well, I’m not sure how the app assignment API works - Isn’t that what I’m hitting with this API? Since we need to revert back a large group of apps to the same user list at a regular cadence, I was thinking, if this worked, a simple POST request on the users href associated to the app would be the easiest way to achieve the end.

Hi @brandlamb,

If you are looking to un assign the users from the app after ‘x’ number of days, you should be ideally getting the list of users assigned to the app using:

GET https://{xxx.okta.com}/api/v1/apps/{appId}/users

followed by iterating the list of users in the response and doing a

DELETE https://{xxx.okta.com}/api/v1/apps/{appId}/users/{userId}

which would un assign the user from the app.

I hope this helps.

Hi @brandlamb

Following @gpadma’s reply, the assignment/unassignment of the users to the application needs to be done individually per user. This operations are described here.

1 Like

This topic was automatically closed 24 hours after the last reply. New replies are no longer allowed.