【问题标题】:How do you paginate with Okta API call?如何使用 Okta API 调用进行分页?
【发布时间】:2022-10-04 16:35:34
【问题描述】:
标签:
bash
api
curl
pagination
okta
【解决方案1】:
# based on https://michaelheap.com/follow-github-link-header-bash/
# Set these:
base_url="https://COMPANY.okta.com"
token="..."
url="$base_url/api/v1/users"
while [ "$url" ]; do
r=$(curl --compressed -Ss -i -H "authorization: SSWS $token" "$url" | tr -d '
')
echo "$r" | sed '1,/^$/d' | jq -r '.[].profile.login'
url=$(echo "$r" | sed -n -E 's/link: <(.*)>; rel="next"//pi')
done