Authdog

Strands Agents

Last updated Oct 22, 2026
View as Markdown

Strands Agents 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 strands/python in authdog/agents-samples. That folder is not published yet, so this page does not pin strands-agents. Python 3.10+.

Channel auth, machine credentials, tool checks, and instructions for this framework are the other pages under Strands Agents in AI.

The hook

class AuthdogHook(HookProvider):
    def register_hooks(self, registry: HookRegistry) -> None:
        registry.add_callback(BeforeToolCallEvent, self.require)

    def require(self, event: BeforeToolCallEvent) -> None:
        token = event.invocation_state.get("authdog_token")
        subject = subject_if_accepted(token)
        if subject is None:
            event.cancel_tool = "unauthorized"
            return
        event.invocation_state["subject"] = subject
        event.invocation_state.pop("authdog_token", None)

Pass the hook to Agent(hooks=[AuthdogHook()]). The host sets authdog_token on invocation state when it calls the agent. The model does not. Setting cancel_tool blocks the tool and returns that message as an error tool result. On accept, the hook stores the subject and removes the token before the tool runs. Tests call require. They do not call a model.

This is agent identity: client_credentials, then this hook. It is not Agent Sign-In. A browser sign-in does not replace the hook.

What you should see

A before-tool event with no token sets cancel_tool to unauthorized. The tool does not run.

A before-tool event with a bearer userinfo accepts leaves cancel_tool unset and stores the subject. whoami returns it.

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

Configure

Name Purpose
Invocation state authdog_token Access token the host passes. Removed before the tool runs.

The shared exchange is in Agent frameworks. There is no refresh token. Repeat it before expires_in.

Read To learn how to
Agent frameworks Mint the bearer this hook checks
Vercel AI SDK The previous hook
LangChain The next hook
Custom channel auth for Strands Agents The same check, as the auth boundary

Learn more