Tokens & Authentication
agent-wechat uses a simple token-based authentication to secure the REST API.
Where the token lives
| Location | Description |
|---|---|
~/.config/agent-wechat/token | File on your host machine. Auto-generated on first wx up. |
/data/auth-token | Inside the container (read-only mount of the host file) |
AGENT_WECHAT_TOKEN env var | Overrides the file-based token |
How the token is used
The token serves two purposes:
- API authentication — every API request must include it in the
Authorizationheader:Authorization: Bearer <token> - Database encryption — the token is used to encrypt
agent.db, the internal database that stores session state and metadata.
The CLI, OpenClaw plugin, and Wechaty puppet all read the token automatically from ~/.config/agent-wechat/token when connecting to localhost.
Generating a token manually
mkdir -p ~/.config/agent-wechatopenssl rand -hex 32 > ~/.config/agent-wechat/tokenchmod 600 ~/.config/agent-wechat/tokenRegenerating the token
Using the CLI:
wx auth token --regenerateOr manually:
openssl rand -hex 32 > ~/.config/agent-wechat/tokenThen restart the container so it picks up the new token:
wx down && wx up# ordocker compose restart agent-wechatRemote access
When connecting to a remote agent-wechat server, you need the token value:
cat ~/.config/agent-wechat/tokenThen set it in your client configuration:
- OpenClaw:
"token": "<value>"in~/.openclaw/openclaw.json - Wechaty:
token: '<value>'in the puppet constructor - CLI:
export AGENT_WECHAT_TOKEN=<value>