Semantic Kernel keeps its own auth hook. Authdog stays the identity provider. The planned sample attaches an agent access token there and refuses the run when that token is missing or userinfo rejects it.

Sample planned at `semantic-kernel/python` in [authdog/agents-samples](https://github.com/authdog/agents-samples). That folder is not published yet, so this page does not pin `semantic-kernel`. Python 3.10+.

Channel auth, machine credentials, tool checks, and instructions for this framework are the other pages under Semantic Kernel in [AI](/docs/ai/semantic-kernel/channel-auth).

## The hook

```python
async def require_authdog(context: FunctionInvocationContext, next):
    token = context.arguments.get("authdog_token")
    subject = subject_if_accepted(token)
    if subject is None:
        return
    context.arguments["subject"] = subject
    del context.arguments["authdog_token"]
    await next(context)

kernel.add_filter(FilterTypes.FUNCTION_INVOCATION, require_authdog)
```

Not calling `next` means the kernel function does not run. The host puts `authdog_token` on the arguments. The filter deletes it before `next`, so the function sees `subject` and not the bearer. Tests invoke the function through the kernel. They do not call a chat model.

This is agent identity: `client_credentials`, then this hook. It is not [Agent Sign-In](/docs/agent-sign-in). A browser sign-in does not replace the hook.

## What you should see

Invoking `whoami` with no token does not enter the function. The result is not a subject.

Invoking `whoami` with a bearer userinfo accepts runs the function. The result is that subject.

`pytest` in `semantic-kernel/python` is how the sample will prove both. It does not call a model.

## Configure

| Name | Purpose |
| --- | --- |
| `authdog_token` argument | Access token the host sets. The filter removes it before the function runs. |

The shared exchange is in [Agent frameworks](/docs/agent-frameworks#mint-the-bearer). There is no refresh token. Repeat it before `expires_in`.

> **Caution**
>
> Do not commit the client secret, and do not put the access token in the prompt. The public key selects the identity host. It does not mint tokens.

## Related

| Read | To learn how to |
| --- | --- |
| [Agent frameworks](/docs/agent-frameworks) | Mint the bearer this hook checks |
| [LlamaIndex Workflows](/docs/agent-frameworks/llamaindex) | The previous hook |
| [Vercel AI SDK](/docs/agent-frameworks/ai-sdk) | The next hook |
| [Custom channel auth for Semantic Kernel](/docs/ai/semantic-kernel/channel-auth) | The same check, as the auth boundary |
