LlamaIndex Workflows 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 `llamaindex/python` in [authdog/agents-samples](https://github.com/authdog/agents-samples). That folder is not published yet, so this page does not pin `the Workflows package that exports `Workflow``. Python 3.10+.

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

## The hook

```python
class WhoamiFlow(Workflow):
    @step
    async def start(self, ev: StartEvent) -> StopEvent:
        subject = getattr(ev, "subject", None)
        if not subject:
            return StopEvent(result="unauthorized")
        return StopEvent(result=f"subject:{subject}")

@app.post("/invoke")
async def invoke(user=Depends(authdog.require_auth)):
    result = await WhoamiFlow().run(subject=subject_of(user))
    return {"reply": result}
```

The route copies the subject from userinfo, then starts the workflow. The bearer stays on the request. A run with no subject returns `unauthorized` and does not continue to a later step. Call `run` only from this route.

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

`POST /invoke` with no token is `401`. `workflow.run()` with no subject returns `unauthorized` and does not contain `subject:`.

The same POST with a bearer userinfo accepts returns `{"reply":"subject:<id>"}`.

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

## Configure

| Name | Purpose |
| --- | --- |
| `PK_AUTHDOG` | Public key on the route. The workflow process does not take the client secret. |

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 |
| [Mastra](/docs/agent-frameworks/mastra) | The previous hook |
| [Semantic Kernel](/docs/agent-frameworks/semantic-kernel) | The next hook |
| [Custom channel auth for LlamaIndex Workflows](/docs/ai/llamaindex/channel-auth) | The same check, as the auth boundary |
