bumpy-controller-43157
06/16/2025, 2:11 PMbrief-egg-61061
06/16/2025, 2:11 PMbrief-egg-61061
06/16/2025, 2:11 PMConfiguration
class to set the base path (your Ory project URL or custom domain), and then instantiate the relevant API class (such as IdentityApi
). Here’s a basic example: java import sh.ory.client.ApiClient; import sh.ory.client.ApiException; import sh.ory.client.Configuration; import sh.ory.client.api.IdentityApi; public class OryClientExample { public static void main(String[] args) { // Set your Ory project URL or custom domain String basePath = "https://{your-project}.<http://projects.oryapis.com|projects.oryapis.com>"; ApiClient defaultClient = Configuration.getDefaultApiClient(); defaultClient.setBasePath(basePath); // Initialize the Identity API IdentityApi apiInstance = new IdentityApi(defaultClient); // Now you can use apiInstance to call Ory APIs } }
Replace {your-project}
with your actual Ory project slug or use your custom domain if configured. If you need to use an API key for admin endpoints, you can set it on the ApiClient
as well. For more details, see the [Ory API Reference](https://www.ory.sh/docs/reference/api) and the [Java SDK documentation](https://github.com/ory/sdk/blob/master/clients/client/java/README.md) [Ory API Reference](https://www.ory.sh/docs/reference/api).bumpy-controller-43157
06/16/2025, 2:21 PMbrief-egg-61061
06/16/2025, 2:21 PMbrief-egg-61061
06/16/2025, 2:21 PMAuthorization
header with your API key. The knowledge sources provide examples for using API keys with the REST API, but do not include a direct Java SDK code sample. However, the general approach is to set the Authorization
header to Bearer <API_KEY>
when making API calls. Here’s how you would do this based on the information from the knowledge sources: 1. Obtain your API key from the Ory Console. It will look like ory_pat_...
for project admin APIs or ory_wak_...
for workspace admin APIs [Authorizing Ory Network Workspace Admin APIs](https://www.ory.sh/docs/concepts/personal-access-token#authorizing-ory-network-workspace-admin-apis). 2. Set the API key as a Bearer token in the Authorization header. For REST API calls, the header should be: Authorization: Bearer <API_KEY>
This is required for privileged (admin) API operations [Manage Ory Network projects through the API](https://www.ory.sh/docs/guides/manage-project-via-api). 3. In the Java SDK, you typically set default headers on the ApiClient
. While the knowledge sources do not provide a Java code example, the equivalent logic is to set the default header for `Authorization`: java import sh.ory.client.ApiClient; import sh.ory.client.Configuration; import sh.ory.client.api.IdentityApi; public class OryClientExample { public static void main(String[] args) { String basePath = "https://{your-project}.<http://projects.oryapis.com|projects.oryapis.com>"; String apiKey = "ory_pat_..."; // Replace with your actual API key ApiClient defaultClient = Configuration.getDefaultApiClient(); defaultClient.setBasePath(basePath); defaultClient.addDefaultHeader("Authorization", "Bearer " + apiKey); IdentityApi apiInstance = new IdentityApi(defaultClient); // Now you can use apiInstance to call Ory APIs } }
Note: The knowledge sources do not provide a Java-specific code sample, but this approach follows the documented requirement to use the Authorization: Bearer <API_KEY>
header for admin API access [Authorizing Ory Network Workspace Admin APIs](https://www.ory.sh/docs/concepts/personal-access-token#authorizing-ory-network-workspace-admin-apis). If you need more details or a Java-specific example from the official documentation, please let me know.