OAuth setup
Create the Google or GitHub OAuth app that people use to sign in to a self-hosted GoPayLocal, and why OAuth is required.
People sign in to GoPayLocal with Google or GitHub. You need at least one of them.
Why OAuth is required
Section titled “Why OAuth is required”Public email sign-up is disabled in the API (emailAndPassword: { disableSignUp: true } in apps/api/src/auth.ts, and a test in apps/api/src/auth.test.ts keeps it that way). Nobody can create an account with an email address and password through the API, so OAuth is how every account gets created.
Email and password sign-in still works for accounts created on the command line with apps/api/scripts/create-test-user.ts. That script exists for automated tests and local development. The dashboard hides the password form unless the login URL has ?pw=1. Do not use it for real accounts.
The callback URL
Section titled “The callback URL”GoPayLocal handles sign-in in the API Worker (with Better Auth). Each provider redirects back to:
<API_BASE_URL>/api/auth/callback/google<API_BASE_URL>/api/auth/callback/githubAPI_BASE_URL is the variable in apps/api/wrangler.toml, for example https://api.example.com. If the API’s hostname changes later, update the callback URL at the provider as well.
GitHub
Section titled “GitHub”-
On GitHub, open Settings > Developer settings > OAuth Apps > New OAuth App (for an organization-owned app, use the organization’s settings).
-
Homepage URL: your dashboard, for example
https://app.example.com. -
Authorization callback URL:
https://api.example.com/api/auth/callback/github. -
Register the app, then generate a client secret.
-
From
apps/api, store both values:Terminal window pnpm wrangler secret put GITHUB_CLIENT_IDpnpm wrangler secret put GITHUB_CLIENT_SECRET
Create an OAuth App, as above, rather than a GitHub App. GoPayLocal asks GitHub for the read:user and user:email scopes (Better Auth’s defaults); a GitHub App would also need its “Email addresses” permission set to read-only. Better Auth’s GitHub guide has more detail.
-
In the Google Cloud console, pick or create a project and set up the OAuth consent screen.
-
Create an OAuth client ID of type Web application.
-
Under Authorized redirect URIs, add
https://api.example.com/api/auth/callback/google. -
From
apps/api, store the client ID and secret:Terminal window pnpm wrangler secret put GOOGLE_CLIENT_IDpnpm wrangler secret put GOOGLE_CLIENT_SECRET
Better Auth’s Google guide has more detail.
Checking it
Section titled “Checking it”Each provider is enabled only when both its client ID and its secret are set. If one is missing, the API logs Google OAuth provider is disabled because GOOGLE_CLIENT_ID or GOOGLE_CLIENT_SECRET is missing. (or the GitHub equivalent) and that provider’s sign-in fails.
The dashboard’s sign-in page always shows both a Google and a GitHub button, so only use the one you configured.
Local development
Section titled “Local development”For wrangler dev, create a separate OAuth app with the callback http://localhost:8787/api/auth/callback/github (or .../google) and put its credentials in apps/api/.dev.vars. CONTRIBUTING.md covers this.