A Val Town service for handling GitHub OAuth authentication with redirect support for external applications.
https://[your-val-url]/auth/callback
In your Val Town environment, set these variables:
GITHUB_CLIENT_ID
: Your GitHub OAuth app client IDGITHUB_CLIENT_SECRET
: Your GitHub OAuth app client secretJWT_SECRET
: A secure random string for signing JWT tokens (generate with openssl rand -base64 32
)Visit your Val Town URL to see the auth page and verify configuration.
https://[your-val-url]/auth/signin?redirect_uri=[your-app-url]
[your-app-url]?token=[jwt-token]
Make a GET request to: https://[your-val-url]/auth/validate?token=[jwt-token]
Returns user profile if token is valid:
{ "valid": true, "user": { "id": 12345, "login": "username", "name": "User Name", "email": "user@example.com", "avatar_url": "https://avatars.githubusercontent.com/u/12345", "html_url": "https://github.com/username" }, "expires_at": 1640995200 }
GET /
- Auth page UI with configuration statusGET /auth/signin?redirect_uri=URL
- Initiate GitHub OAuth flowGET /auth/callback
- Handle GitHub OAuth callback (internal)GET /auth/validate?token=JWT
- Validate JWT token and return user infoGET /health
- Health check with configuration statusSee /examples/client-integration.md
for detailed integration examples including:
├── backend/
│ └── index.ts # Main Hono server with OAuth routes
├── frontend/
│ └── index.html # Auth page UI
├── shared/
│ └── types.ts # Shared TypeScript types
├── examples/
│ └── client-integration.md # Integration examples
└── README.md # This file
The service provides clear error messages for:
The service gracefully handles missing environment variables during development, showing configuration warnings in the UI and API responses.