brash-raincoat-15175
08/18/2024, 7:26 PMconst identityClient = new sdk.IdentityApi({
apiKey: process.env.KRATOS_API_KEY,
basePath: process.env.KRATOS_ADMIN_URL,
isJsonMime,
});
And then I'm trying to run the following code:
const response = await identityClient.getIdentity({ id });
However, I'm getting a 401 from Ory. I double checked the api key is correct and the admin url is also correct.chilly-king-10285
08/18/2024, 7:26 PMchilly-king-10285
08/18/2024, 7:26 PMAuthorization
header of your requests. However, in the code you've provided, it seems like you're trying to pass the API key as a parameter when instantiating the IdentityApi
client. This might be the reason why you're encountering a 401 error. Here's how you can include the API key in your requests: javascript GET /admin/identities HTTP/1.1 Host: $<http://PROJECT_SLUG.projects.oryapis.com|PROJECT_SLUG.projects.oryapis.com> Accept: application/json Authorization: Bearer $API_KEY
In this example, $API_KEY
should be replaced with your actual API key. Note that the API key should be prefixed with Bearer
in the Authorization
header. Also, remember that API keys are bound to a specific Ory Network project and not to a specific user. This means that any user with access to the API key can perform the operations that the API key allows, even if they are no longer part of the project. Therefore, it's important to keep your API keys secure and rotate them if necessary. For more information on how to use API keys with the Ory API, you can refer to the following documentation: - [Authorizing Ory Network Project Admin APIs](https://www.ory.sh/docs/concepts/personal-access-token#authorizing-ory-network-project-admin-apis) - [Ory APIs](https://www.ory.sh/docs/getting-started/local-development#ory-apis) - [Authorizing Ory Network Workspace Admin APIs](https://www.ory.sh/docs/concepts/personal-access-token#usage-1)brash-raincoat-15175
08/18/2024, 7:27 PMchilly-king-10285
08/18/2024, 7:27 PMchilly-king-10285
08/18/2024, 7:27 PMbrash-raincoat-15175
08/18/2024, 7:31 PMapiKey
. Anyway, thanks Kapa!