How to Call a Private Google Cloud Run Service From Outside Google Cloud With Identity Tokens
A program outside Google Cloud needs two things to call a Cloud Run service protected by Identity and Access Management (IAM): a…
When a client reads many records from an API, the server returns them in pages instead of one large response. A filter picks which records to include, and a sort rule sets their order. The server also sends a continuation token (a value the client passes back to ask for the next page) or a next-page URL so the client knows where to resume. To keep every page part of the same result set, the client should preserve the original filter and sort rules while following the API’s documented method for fetching the next page.
Each API decides whether its continuation value carries those filter and sort rules. Some APIs expect the client to send the original query parameters on every request; others bake that state into a token or next-page link. If a user changes a filter or sort order while browsing, the client should discard the old continuation value and request the first page of the new query. The API documentation should state how this works.
The client should treat the filter and sort order from the first page as a single query. It should store those settings alongside the continuation value, along with any other options that affect the results, such as the API version.
Different APIs enforce different rules for follow-up requests. Google’s AIP-158 pagination guidance says clients should keep request arguments unchanged when passing a page token, though they may change the page size. Under that guidance, the server returns INVALID_ARGUMENT if another argument changes. Microsoft’s current Azure REST API Guidelines also instruct clients to keep the same filtering options and sort order on every page.
When a server returns a complete URL for the next page, the client should follow that URL as given instead of rebuilding it by hand. Microsoft Graph, for example, tells clients to treat the full @odata.nextLink as an opaque value, meaning the client passes the URL along without reading or editing it. Some Graph requests also require a ConsistencyLevel header on later pages, so the client must keep required headers intact while following the link. The Graph paging documentation covers that requirement in detail.
A token on its own does not mean the server saved your filter and sort rules for the next call. AIP-158 requires clients to send the same arguments again. Microsoft Graph delta queries are a specific exception: their state tokens include query parameters from the first request, so clients follow the returned link without repeating those parameters. That behavior only applies to documented delta queries, so clients should not assume other pagination tokens work the same way.
If a user changes a filter or sort order while browsing, the client should clear the old token or next-page link and request the first page of the new query. Otherwise, later pages can mix records from two different result sets. The client should do anything else only when the API explicitly allows parameters to change mid-traversal.
The API should state what the server does when a client sends a continuation value with changed parameters. The server might reject the request, ignore the new values, or allow the change under a documented rule. No single status code covers every API when parameters mismatch. AIP-158 recommends returning INVALID_ARGUMENT when an argument other than page size changes, though that is Google’s design guidance rather than a universal standard.
Clients should treat tokens and continuation URLs as opaque unless the API says otherwise. Put the token in the documented field or follow the returned URL without changing it. Microsoft Data API builder, for example, states that clients must not construct or modify its $after token, and that schema or sort-order changes invalidate previously issued tokens. Those rules apply specifically to Data API builder. Understanding cursor tokens gives more background on why clients should leave cursor contents alone.
The server should filter records first, sort the remaining records, and then divide them into pages. Microsoft’s deprecated Graph-specific REST guidance describes that order. Microsoft’s Azure architecture guidance recommends deterministic sorting so records stay in a defined order across requests. When several records share the same sort value, the server can add a unique tie-breaker, such as a record identifier, to fix their order.
A stable sort does not freeze the underlying data while the client reads through pages. If someone adds, removes, or updates records during the traversal, later pages can still skip or repeat records unless the server provides a snapshot or another consistency guarantee. Microsoft’s current Azure REST guidelines tell API authors to document that records may be skipped or duplicated unless the endpoint includes a safeguard such as a time-limited snapshot. Clients should not assume a continuation token gives them a snapshot.
API documentation should tell clients how to request the next page and which parameters to keep. Spell out the filters, sort rules, versions, and headers that must stay the same. Also state whether clients can change the page size, whether a token stores any query state, and what the server does if a parameter changes mid-traversal.
The documentation should also explain how tokens behave in practice: whether clients must treat a token or URL as opaque, when a token expires or becomes invalid, and how the client knows it has reached the last page. Microsoft Graph signals the last page by omitting @odata.nextLink. Microsoft Fabric documents that its continuation fields disappear or become null when no results remain. Documenting the exact response keeps clients from guessing.
Clients should test a complete walk through every page instead of testing single page requests in isolation. Check that later requests keep the original filter and sort, that a changed query triggers the documented error or starts a fresh traversal, and that the client recognizes the last page. Also verify that the endpoint supports the filter and sort combination you need, since support can vary by operation and API version.
Give Vroni a GitHub issue, bug report, spec, or rough idea. It reads the repo, plans the change, writes code, runs checks, and works toward a review-ready pull request.
Take a look at vroni.com