CLI API
Device Code Flow
The recommended authentication method for CLI and terminal applications. Users log in via their browser without entering credentials in the terminal. For scripts and integrations, API keys are simpler.
1
1. Start the flow
Call POST /cli/auth/start to receive a device code and verification URL.
bash
curl -X POST https://api.playanagrama.com/cli/auth/start \
-H "Content-Type: application/json" \
-d '{"label":"terminal","clientName":"my-app"}'Response
JSON
{
"device_code": "abc123",
"user_code": "ABCD-1234",
"verification_url": "https://playanagrama.com/cli-auth?code=ABCD-1234",
"expires_in": 900,
"interval": 5
}2
2. User visits the verification URL
Direct the user to open verification_url in their browser. They sign in and authorize the CLI session.
3
3. Poll for completion
Poll POST /cli/auth/poll at the specified interval until status is "success".
bash
curl -X POST https://api.playanagrama.com/cli/auth/poll \
-H "Content-Type: application/json" \
-d '{"device_code":"abc123"}'Success Response
JSON
{
"status": "success",
"token": "cli_...",
"user": {
"userId": "user_xxx",
"username": "player1",
"displayName": "Player One"
}
}4
4. Use the token
Include the token as a Bearer token in the Authorization header for all game endpoints.
Header
Authorization: Bearer cli_...Was this page helpful?