dazzling-egg-44499
01/13/2023, 2:07 PMhandsome-agency-20541
01/13/2023, 2:32 PMcurl -q -H 'Authorization: Bearer '$ORY_PAT $ORY_HTTP_BASE'/admin/identities?per_page=1' -v
âŚ
< link: <https://âŚ.projects.oryapis.com/identities?page=0&page_size=1&page_token=eyJvZmZzZXQiOiIwIiwidiI6Mn0&per_page=1>; rel="first",<https://âŚ.projects.oryapis.com/identities?page=0&page_size=1&page_token=eyJvZmZzZXQiOiIwIiwidiI6Mn0&per_page=1>; rel="prev"
Wouldâve been nice to have this documented though.handsome-agency-20541
01/13/2023, 2:33 PMLink
header is experimental, and some browsers do not support it.dazzling-egg-44499
01/13/2023, 2:48 PMdazzling-egg-44499
01/17/2023, 4:02 PMhandsome-agency-20541
01/17/2023, 4:07 PMpage
query parameter by any chance?dazzling-egg-44499
01/17/2023, 4:07 PMdazzling-egg-44499
01/17/2023, 4:08 PMdazzling-egg-44499
01/17/2023, 4:08 PMhandsome-agency-20541
01/17/2023, 4:09 PMdazzling-egg-44499
01/17/2023, 4:10 PMdazzling-egg-44499
01/17/2023, 4:10 PMhandsome-agency-20541
01/17/2023, 4:11 PMhandsome-agency-20541
01/17/2023, 4:11 PMpage=1
is the default, but apparently the responses differ with and without it.dazzling-egg-44499
01/17/2023, 4:16 PMdazzling-egg-44499
01/17/2023, 4:18 PMhandsome-agency-20541
01/17/2023, 4:20 PMpage_token
parameter, which seemingly makes page=1
work properly.handsome-agency-20541
01/17/2023, 4:20 PMbright-london-67419
01/17/2023, 8:24 PMconst identities: Identity[] = []
let totalCount = 0
let hasNext = true
let page: number | undefined = 0
while (hasNext) {
// Note: this call is paginated, return 250 records `perPage` by default
const res = await kratosAdmin.listIdentities({ perPage, page })
identities.push(...res.data)
totalCount = Number(res.headers["x-total-count"])
page = getNextPage(res.headers.link)
hasNext = page !== undefined && totalCount !== 0
}
// * fixes bug in kratos res.headers.link not returning last page properly
const pageCount = totalCount / perPage
const isPageCountWholeNumber = pageCount % 1 // 0 means its a whole number, therefore, we can skip because no partial last page of data exists
if (isPageCountWholeNumber !== 0) {
const lastPageNum = Math.ceil(totalCount / perPage)
const lastPageRes = await kratosAdmin.listIdentities({
perPage,
page: lastPageNum,
})
identities.push(...lastPageRes.data)
}
handsome-agency-20541
01/18/2023, 7:37 AMpage_size=3
I canât access the 4th identity at all.dazzling-egg-44499
01/18/2023, 2:21 PMhandsome-agency-20541
01/18/2023, 5:00 PMbright-london-67419
01/19/2023, 4:30 PMdazzling-egg-44499
02/03/2023, 11:46 AMdazzling-egg-44499
02/03/2023, 11:50 AMdazzling-egg-44499
02/03/2023, 11:59 AM