Retrieve Okta Advanced Server Access Users With Pagination via the API
Last Updated:
Overview
Retrieve Okta Advanced Server Access (ASA) users with pagination through the Application Programming Interface (API) by creating a service user, generating an API key, and executing a series of curl commands.
Applies To
- Okta Identity Engine (OIE)
- Okta Classic Engine
- Okta Advanced Server Access (ASA)
- Application Programming Interface (API)
Solution
How are Okta Advanced Server Access users retrieved with pagination via the API?
Create a service user, generate an API key, and execute the required API requests to retrieve the paginated user list by following these steps:
- Create a service user and assign it to an admin group.
- Create an API key for the service user and record the key and secret for use in the subsequent steps.
- Update the
<asa-team>,<key>, and<secret>values in the following command and execute it:curl -v -H "Content-Type: application/json" -X POST "https://app.scaleft.com/v1/teams/<asa-team>/service_token" -d '{ "key_id": "<key>", "key_secret": "<secret>" }'
- Copy the
bearer_tokenvalue from the output and use it as the<token>in the following command:curl -i -s GET "https://app.scaleft.com/v1/teams/<asa-team>/users?count=100" --header 'Accept: application/json' --header 'Content-Type: application/json' --header 'Authorization: Bearer <token>'
- Review the returned values and locate the link header showing a URL with an offset username value, similar to the following example:
link: <https://app.scaleft.com/v1/teams/<asa-team>/users?count=100&descending=true&offset=<user_name>>; rel="prev"
- Insert the offset value from step 5 into the command from step 4 and execute it again. The updated request appears as follows:
curl -i -s GET "https://app.scaleft.com/v1/teams/<asa-team>/users?count=100&offset=<user_name>" --header 'Accept: application/json' --header 'Content-Type: application/json' --header 'Authorization: Bearer <token>'
- Repeat steps 5 and 6 to retrieve the complete user list.
