Skip to content

Tokens & Authentication

agent-wechat uses a simple token-based authentication to secure the REST API.

Where the token lives

LocationDescription
~/.config/agent-wechat/tokenFile on your host machine. Auto-generated on first wx up.
/data/auth-tokenInside the container (read-only mount of the host file)
AGENT_WECHAT_TOKEN env varOverrides the file-based token

How the token is used

The token serves two purposes:

  1. API authentication — every API request must include it in the Authorization header:
    Authorization: Bearer <token>
  2. 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

Terminal window
mkdir -p ~/.config/agent-wechat
openssl rand -hex 32 > ~/.config/agent-wechat/token
chmod 600 ~/.config/agent-wechat/token

Regenerating the token

Using the CLI:

Terminal window
wx auth token --regenerate

Or manually:

Terminal window
openssl rand -hex 32 > ~/.config/agent-wechat/token

Then restart the container so it picks up the new token:

Terminal window
wx down && wx up
# or
docker compose restart agent-wechat

Remote access

When connecting to a remote agent-wechat server, you need the token value:

Terminal window
cat ~/.config/agent-wechat/token

Then 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>