【问题标题】:How do you paginate with Okta API call?如何使用 Okta API 调用进行分页?
【发布时间】:2022-10-04 16:35:34
【问题描述】:

抱歉这个愚蠢的问题,但我在 7 年前看到了这个帖子,但我想知道如何做同样的事情:

How to get next page from Okta api call with CURL

我看到传递给 curl 以获取“下一个”URL 的“-i”标志,但我仍然不完全确定如何循环通过标头中提供的后续 URL,直到没有进一步的结果返回。感谢您的任何建议!

【问题讨论】:

    标签: 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
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2013-10-28
      • 2020-03-22
      • 2021-06-02
      • 2021-02-06
      相关资源
      最近更新 更多