lively-scientist-17848
12/11/2024, 9:40 AMbrief-egg-61061
12/11/2024, 9:40 AMbrief-egg-61061
12/11/2024, 9:40 AMyaml selfservice: methods: oidc: config: after: hooks: - hook: web_hook config: url: <https://your-webhook-endpoint.com> method: POST body: "..."
In this configuration, replace <https://your-webhook-endpoint.com>
with the actual URL of your webhook endpoint. When a user links an OIDC provider to their existing password account, this webhook will be triggered, allowing you to perform any necessary actions or record the event in your system. For more detailed information on configuring webhooks and the available triggers, you can refer to the [Ory Kratos Hooks documentation](https://www.ory.sh/docs/kratos/hooks/configure-hooks#action-triggers).lively-scientist-17848
12/11/2024, 9:41 AMbrief-egg-61061
12/11/2024, 9:41 AMbrief-egg-61061
12/11/2024, 9:41 AMcredentials
field of the identity object, specifically under the oidc
key. 3. Look for the providers
array within the oidc
credentials. Each object in this array represents a linked provider. Here's an example of what the relevant part of the webhook payload might look like: json { "credentials": { "oidc": { "type": "oidc", "identifiers": [ "google:some-user", "github:another-user" ], "config": { "providers": [ { "subject": "some-user", "provider": "google", "initial_access_token": "********************", "initial_refresh_token": "********************", "initial_id_token": "********************", }, { "subject": "another-user", "provider": "github", "initial_access_token": "********************", "initial_refresh_token": "********************", "initial_id_token": "********************", } ] } } } }
In this example, you can see that the user has linked both Google and GitHub as OIDC providers. The most recently linked provider will typically be the last one in the providers
array. To determine which provider was just linked, you can: 1. Compare the providers
array with the previous state of the identity (if you have access to it). 2. Look at the updated_at
timestamp of the oidc
credentials to see if it matches the time of the webhook call. Remember that the exact structure of the webhook payload may vary depending on your Ory configuration and version. Always refer to the [Ory documentation](https://www.ory.sh/docs/kratos/social-signin/get-tokens) for the most up-to-date information on identity structures and OIDC provider data.