sculk.network
Nightly Stable docs
OAuthMCnightly · 39a95aaView in Stable docs

Getting started

This guide builds the OAuthMC container locally, starts it, creates a verification ticket, joins with Minecraft, and redeems the code.

Every command runs in a terminal on the host. Each command block is followed by the output you see. Values in angle brackets, like <ticket_id>, change on every run.

Prerequisites#

  • Docker Engine
  • curl and openssl
  • Minecraft Java Edition (or the test client in tests/clients/ for local testing without a real Minecraft account)

1. Build the container image#

The prebuilt image at ghcr.io/yellowumbrelladev/oauthmc is not published yet; it ships with the first stable release. Until then, build the image from the crates/oauthmc directory (or pass crates/oauthmc from the monorepo root):

sh
docker build -t oauthmc crates/oauthmc

The build compiles a static Linux musl binary and packages it into a non-root distroless image. It finishes with:

text
 => => naming to docker.io/library/oauthmc:latest

2. Generate an API key and start OAuthMC#

Every key in OAUTHMC_API_KEYS must be at least 32 characters long. Generate a random 48-character hex key:

sh
API_KEY=$(openssl rand -hex 24)
echo "$API_KEY"
text
<48 hex characters>

Start the container. Expose port 25565 for Minecraft clients and bind port 8080 to 127.0.0.1 so the HTTP API stays private:

sh
docker run -d --name oauthmc \
  -p 25565:25565 \
  -p 127.0.0.1:8080:8080 \
  -e OAUTHMC_API_KEYS="$API_KEY" \
  -e OAUTHMC_PUBLIC_ADDRESS="verify.example.com" \
  oauthmc
text
<container id>

Check the startup log and the health probe:

sh
docker logs oauthmc
text
level=info event=listening mc_addr=0.0.0.0:25565 api_addr=0.0.0.0:8080
sh
curl -sS http://127.0.0.1:8080/healthz
json
{"ok":true}

3. Create a ticket#

Replace HatsuneMiku with the Minecraft Java username you want to verify:

sh
curl -sS -X POST http://127.0.0.1:8080/v1/tickets \
  -H "Authorization: Bearer $API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"name":"HatsuneMiku"}'
json
{"address":"verify.example.com","exclusive":false,"expires_at":"2026-11-26T10:32:09Z","id":"tkt_823fc8dac7451029a38794aef229ea24","max_attempts":5,"metadata":null,"mode":"code","name":"HatsuneMiku","status":"pending"}

Save the returned id as TICKET_ID:

sh
TICKET_ID="tkt_823fc8dac7451029a38794aef229ea24"

4. Join the Minecraft server#

Open Minecraft Java Edition, go to Multiplayer, add 127.0.0.1:25565 (or your OAUTHMC_PUBLIC_ADDRESS), and join.

OAuthMC completes the online-mode login handshake against Mojang's session server and disconnects you with a one-time 8-character code:

text
Your verification code: N6AN-46TW
Enter it on the website (expires in 15 min).
Never share this code with anyone.

You can confirm the ticket moved from pending to joined:

sh
curl -sS "http://127.0.0.1:8080/v1/tickets/$TICKET_ID" \
  -H "Authorization: Bearer $API_KEY"
json
{"attempts_left":5,"expires_at":"2026-11-26T10:32:09Z","id":"tkt_823fc8dac7451029a38794aef229ea24","metadata":null,"mode":"code","name":"HatsuneMiku","status":"joined"}

GET /v1/tickets/{id} never returns the player's Mojang UUID.

5. Redeem the code#

Send the code from the disconnect screen to POST /v1/tickets/{id}/redeem. Matching ignores case and dashes:

sh
curl -sS -X POST "http://127.0.0.1:8080/v1/tickets/$TICKET_ID/redeem" \
  -H "Authorization: Bearer $API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"code":"N6AN-46TW"}'
json
{"name":"HatsuneMiku","uuid":"a0c4b8c5-a04f-4a6f-9d02-1dea6154a9f6"}

Redeeming consumes the ticket. A second redeem returns 409 Conflict:

json
{"error":"not_redeemable","message":"ticket cannot be redeemed in its current status","status":"redeemed"}

If you send a wrong code before redeeming, OAuthMC returns 422 Unprocessable Entity and decrements attempts_left:

json
{"attempts_left":4,"error":"wrong_code","message":"verification code does not match"}

6. Clean up#

Remove the test container when you finish:

sh
docker rm -f oauthmc
text
oauthmc

Next steps#

  • Read Integrating OAuthMC to wire code mode or link mode into your backend and UI.
  • Read Configuration to tune TTLs, rate limits, MOTD, favicon, and message templates.
  • Read Deploying to run OAuthMC with Docker Compose, DNS SRV records, or a TCP proxy.