<@U04UQ68083H> how to send webhook from ory hydra ...
# ory-copilot
b
@chilly-king-10285 how to send webhook from ory hydra with api key in http header
c
A message from kapa.ai
To send a webhook from Ory Hydra with an API key in the HTTP header, you can use the Ory CLI to register your webhook endpoint. Here is an example of how to do this:
Copy code
bash ory patch oauth2-config --project <project-id> --workspace <workspace-id> \     --add '/oauth2/token_hook/url="<https://my-example.app/token-hook>"' \     --add '/oauth2/token_hook/auth/type="api_key"' \     --add '/oauth2/token_hook/auth/config/in="header"' \     --add '/oauth2/token_hook/auth/config/name="X-API-Key"' \     --add '/oauth2/token_hook/auth/config/value="MY API KEY"' \     --format yaml
In this command, replace
<project-id>
and
<workspace-id>
with your project and workspace IDs. Also, replace
"<https://my-example.app/token-hook>"
with your webhook endpoint URL, and
"MY API KEY"
with your actual API key. This command will register your webhook endpoint with Ory Hydra, and configure it to send the API key in the HTTP header when making requests to your endpoint. For more information, refer to the [Ory Hydra documentation](https://www.ory.sh/docs/hydra/guides/claims-at-refresh#configuration).
b
@chilly-king-10285 and with environment variables set?
c
A message from kapa.ai
To set environment variables for Ory Hydra, you can use the
export
command in Unix-based systems (like macOS and Linux) or the
set
command in Windows CMD. Here are examples for each: For macOS and Linux:
Copy code
bash export ORY_SDK_URL=https://$<http://PROJECT_SLUG.projects.oryapis.com|PROJECT_SLUG.projects.oryapis.com>
For Windows CMD:
Copy code
cmd set ORY_SDK_URL=https://$<http://PROJECT_SLUG.projects.oryapis.com|PROJECT_SLUG.projects.oryapis.com>
In these commands, replace
$PROJECT_SLUG
with your actual project slug. These commands will set the
ORY_SDK_URL
environment variable to the URL of your Ory project's APIs. For more information, refer to the [Ory documentation](https://www.ory.sh/docs/getting-started/integrate-auth/expressjs#run-your-expressjs-app).
b
@chilly-king-10285 which environment variables do i have to set if i want to send api key in http headers from hydra to a webhook url
c
A message from kapa.ai
To send an API key in HTTP headers from Hydra to a webhook URL, you don't directly set environment variables. Instead, you use the Ory CLI to configure the webhook endpoint with the API key in the HTTP header. Here is an example:
Copy code
bash ory patch oauth2-config --project <project-id> --workspace <workspace-id> \     --add '/oauth2/token_hook/url="<https://my-example.app/token-hook>"' \     --add '/oauth2/token_hook/auth/type="api_key"' \     --add '/oauth2/token_hook/auth/config/in="header"' \     --add '/oauth2/token_hook/auth/config/name="X-API-Key"' \     --add '/oauth2/token_hook/auth/config/value="MY API KEY"' \     --format yaml
In this command, replace
<project-id>
and
<workspace-id>
with your project and workspace IDs. Also, replace
"<https://my-example.app/token-hook>"
with your webhook endpoint URL, and
"MY API KEY"
with your actual API key. This command will register your webhook endpoint with Ory Hydra, and configure it to send the API key in the HTTP header when making requests to your endpoint. For more information, refer to the [Ory Hydra documentation](https://www.ory.sh/docs/hydra/guides/claims-at-refresh#configuration).