bumpy-controller-43157
05/15/2025, 11:22 AMbrief-egg-61061
05/15/2025, 11:22 AMbrief-egg-61061
05/15/2025, 11:23 AMpom.xml
configuration. ### Maven pom.xml
Dependency Add the Ory Java client to your Maven dependencies: xml <dependencies> <dependency> <groupId>sh.ory</groupId> <artifactId>ory-client</artifactId> <version>0.39.0</version> <!-- Use the latest version from Maven Central --> </dependency> </dependencies>
You can find the latest version and more details here: [Ory Java client on Maven](https://search.maven.org/artifact/sh.ory/ory-client) [Ory SDK documentation](https://www.ory.sh/docs/sdk/) --- ### Kotlin Boilerplate Example This example demonstrates how to instantiate the Ory Identity API client and list users (identities) in your Ory Network project. kotlin import sh.ory.client.ApiClient import sh.ory.client.api.IdentityApi import sh.ory.client.model.Identity fun main() { // Replace with your Ory Network project slug and API key val projectSlug = "your-project-slug" val apiKey = "your-ory-network-api-key" // Set up the Ory API client val apiClient = ApiClient() .setBasePath("https://$<http://projectSlug.projects.oryapis.com|projectSlug.projects.oryapis.com>") .addDefaultHeader("Authorization", "Bearer $apiKey") val identityApi = IdentityApi(apiClient) // List identities (users) try { val identities = identityApi.listIdentities(null, null, null, null) for (identity: Identity in identities) { println("Identity ID: ${identity.id}") } } catch (e: Exception) { println("Error fetching identities: ${e.message}") } }
- Replace your-project-slug
with your Ory Network project slug. - Replace your-ory-network-api-key
with your Ory Network API key (create one in the Ory Console under Project settings → API Keys). For more details on the Java client and available methods, see the [Ory Java SDK README](https://github.com/ory/sdk/blob/master/clients/client/java/README.md) and the [Ory API reference](https://www.ory.sh/docs/reference/api). --- If you need to perform other user management operations (create, update, delete), refer to the methods available in the IdentityApi
class as described in the SDK documentation. Let me know if you need a specific example for creating or updating users!bumpy-controller-43157
05/15/2025, 2:37 PMbrief-egg-61061
05/15/2025, 2:37 PMbrief-egg-61061
05/15/2025, 2:38 PMLink
HTTP header with URLs for the first
and next
pages, each containing a page_token
parameter. The number of items per page is controlled by the page_size
parameter in your request, but the API does not return the total number of items or the current page index in the response. This means you cannot directly map Ory’s pagination to Spring’s `Page`/`Pageable` without additional logic or tracking on your side. Here’s how Ory’s pagination works: - You specify page_size
(number of items per page) and optionally page_token
(for the next page). - The response includes a Link
header with URLs for the next and first pages. - There is no total count or current page number in the response payload or headers. - You must treat the page_token
as an opaque string and use it for subsequent requests. - Offset-based pagination (per_page
and page
) is deprecated and not recommended for new implementations, and it also does not guarantee sequential page numbers or total counts [API REST Pagination](https://www.ory.sh/docs/guides/api-rest-pagination/) [API Design](https://www.ory.sh/docs/ecosystem/api-design/) [Offset Pagination Deprecated](https://www.ory.sh/docs/guides/api-rest-pagination/#offset-pagination-deprecated). Implications for Spring Integration: - You can set the page size to match Spring’s Pageable
, but you cannot provide the total number of items or the current page index. - To integrate with Spring’s `Page`/`Pageable`, you would need to implement a custom adapter that: - Uses Ory’s page_token
for navigation. - Leaves total count and page number fields empty or estimated, as this information is not available from Ory. - If you require total counts or page numbers, you would need to fetch all items (which is not efficient or recommended). Summary: Ory’s token-based pagination does not provide enough information (such as total item count or current page number) to fully integrate with Spring’s `Page`/`Pageable` out of the box. You can only provide the current page size and use the Link
header for navigation, but not the total number of items or pages [API REST Pagination](https://www.ory.sh/docs/guides/api-rest-pagination/) [API Design](https://www.ory.sh/docs/ecosystem/api-design/). If you need more details or a code example for a custom adapter, let me know!bumpy-controller-43157
05/15/2025, 2:39 PMbrief-egg-61061
05/15/2025, 2:39 PMbrief-egg-61061
05/15/2025, 2:40 PMpage_token
(an opaque string) and page_size
for navigation, and does not provide total item counts or page numbers in the response. The only way to get the next page is to use the page_token
from the Link
header in the previous response. There is no direct mapping to Spring’s `Pageable`/`Page` because Spring expects offset and total count information, which Ory does not provide [API REST Pagination](https://www.ory.sh/docs/guides/api-rest-pagination/) [API Design](https://www.ory.sh/docs/ecosystem/api-design/). What you can do: - You can create a custom adapter or wrapper that uses Ory’s page_token
and page_size
to fetch data, and then wraps the result in a Spring Page
object. - However, you will not be able to provide the total number of items or the current page number, as this information is not available from Ory. - You can set the `Page`’s totalElements
and totalPages
to -1
or 0
, and only provide the content and the page_token
for the next page. Example approach (conceptual, not full code): kotlin data class OryPage<T>( val content: List<T>, val nextPageToken: String? ) fun <T> toSpringPage(oryPage: OryPage<T>, pageable: Pageable): Page<T> { // Since Ory does not provide total count, set totalElements to -1 or 0 return PageImpl( oryPage.content, pageable, -1 // or 0, as total count is unknown ) }
You would need to manage the mapping between Spring’s Pageable
and Ory’s page_token
yourself, for example by storing the mapping of page numbers to tokens in the user’s session or in a cache. Limitations: - You cannot support random access to pages (e.g., jumping to page 5) because Ory’s tokens are sequential and opaque. - You cannot provide total counts or total pages. Summary: You can wrap Ory’s paginated results in a Spring Page
object for compatibility, but you must accept the limitations: no total count, no random page access, and manual management of page_token
navigation. This is a common challenge when integrating token-based APIs with offset-based frameworks like Spring [API REST Pagination](https://www.ory.sh/docs/guides/api-rest-pagination/) [API Design](https://www.ory.sh/docs/ecosystem/api-design/). If you need a more detailed code example, let me know!