From 0946c1845dfde2905d799d38bbb09fb21763b768 Mon Sep 17 00:00:00 2001 From: "M. L. Giannotta" Date: Sun, 10 May 2026 16:04:33 +0800 Subject: [PATCH] docs: fix authentication section in README The HTTP API uses a JWT-based scheme, not an "ApiKey " scheme. `auth/login.go` accepts `Authorization: Bearer ` on `/auth/login`, returns a JWT, and the JwtAuthMiddleware then expects `Authorization: Bearer ` on every `/api/*` request. The previous example would 401. Replace the section with the actual two-step flow plus a working `curl` invocation for each step. Also fix the endpoint path (`/api/messages`, not `/messages`). --- README.md | 23 ++++++++++++++++------- 1 file changed, 16 insertions(+), 7 deletions(-) diff --git a/README.md b/README.md index 739c6ab..cba0ec2 100644 --- a/README.md +++ b/README.md @@ -99,18 +99,27 @@ docker compose up ## Authentication -The HTTP API is protected using **API Key or JWT authentication**. +The HTTP API uses a two-step **API key → JWT** flow. The `API_KEY` you set in +`docker-compose.yaml` is exchanged for a short-lived JWT, which is then used +on every subsequent request to `/api/*`. -You must include one of the following headers in every request. +### 1. Exchange the API key for a JWT -### API Key +```bash +curl -X POST http://localhost:8080/auth/login \ + -H "Authorization: Bearer " +# => {"token":""} +``` -Authorization: ApiKey +### 2. Call protected endpoints with the JWT -Example: +```bash +curl -H "Authorization: Bearer " \ + http://localhost:8080/api/messages +``` -curl -H "Authorization: ApiKey your-api-key" \ -http://localhost:8080/messages +The MCP server handles this exchange automatically — you only need to set the +`WHATSAPP_API_SECRET` environment variable to match the bridge's `API_KEY`. ## Architecture Overview