This Next.js app hosts the OAuth callback and token exchange endpoints used by the RoamJS Google extension.
GET /oauth- OAuth callback page.
- For browser flows, it posts auth params back to the opener.
- For desktop/poll flows, it also registers callback completion to
/oauth/session.
GET /oauth/session?session=...- Poll endpoint for desktop-safe OAuth handoff.
POST /oauth/session- Callback registration endpoint for
{ session, code, state, error }.
- Callback registration endpoint for
POST /google-auth- Exchanges Google auth code or refresh token for access token data.
- Install dependencies:
npm install
- Create local env:
cp .env.example .env.local
- Set required env vars in
.env.local:GOOGLE_OAUTH_CLIENT_IDGOOGLE_OAUTH_CLIENT_SECRET
- Run:
npm run dev
/oauth/sessionuses edge cache storage when available, with in-memory fallback.- If polling misses under heavy scale, move session storage to dedicated shared KV/Redis.