Skip to main content
This page covers the companion auth service repo. The auth service makes AniList account linking work for /register.

What the auth service does

The auth service:
  • receives the signed OAuth context from the bot
  • validates the context and creates a single-use OAuth state
  • redirects the browser to AniList
  • handles the AniList callback
  • exchanges the auth code for AniList tokens
  • fetches the AniList viewer ID and stores the linked credentials
  • owns annie_auth.oauth_credentials, annie_auth.oauth_sessions, and annie_auth._sqlx_migrations in the shared PostgreSQL database
  • serves GET /healthz for liveness and GET /readyz for database readiness

Before you start

You need an AniList OAuth application with a callback URL that points to the auth service. For local development, use:

Configure the auth environment

From a workspace where the bot repo and auth repo are siblings:
Then edit .env:
DATABASE_URL and OAUTH_CONTEXT_SIGNING_SECRET must match the bot service values. Keep USERID_HASH_SALT aligned too if you want matching hashed user identifiers across logs.

Run the auth service locally

1

Create the auth database

Create the shared PostgreSQL database or connection target you want both services to use.
2

Start the service

On startup, the service connects to PostgreSQL, creates the annie_auth schema when needed, runs SQLx migrations with search_path=annie_auth,public, and serves the AniList OAuth routes.
3

Verify the health endpoints

/healthz reports process liveness without checking PostgreSQL. /readyz waits up to two seconds for a database check and returns 503 Service Unavailable when PostgreSQL is unavailable.

Deployment health check

The auth repo’s railway.toml binds Rocket to 0.0.0.0:$PORT, uses /readyz as the deployment health check, allows 60 seconds for deployment health, and restarts the service on failure up to five times.

Verify the OAuth flow

  1. Start the bot service.
  2. Run /register in Discord.
  3. Click Link AniList Account.
  4. Complete the AniList flow in the browser.
  5. Run /whoami to confirm the linked profile.