# Google sign-in The admin login offers "Sign in with Google" for @nextgenerationofunity.org accounts, alongside email and password. It's off until the service has an OAuth client ID and secret. ## Who gets in Only accounts that already exist. Create them as before with `admin-cli.js add ` (the password it asks for stays as a way in if Google is ever unavailable). The first time that person signs in with Google, their Google account is linked to the admin account with the same email; after that it matches by the link, even if the email later changes. `admin-cli.js list` shows which accounts are linked. Refused, with a message on the login page: no admin account for that email, an email already linked to a different Google account, a disabled account, any account outside the Workspace domain (checked by Google's `hd` claim, not just the email), an unverified email. Code: `server/src/googleAuth.js` (the Google side) and `server/src/routes/auth.js` (matching and linking accounts). ## Setting up the OAuth client In [Google Cloud Console](https://console.cloud.google.com/), signed in as a Workspace admin for nextgenerationofunity.org: 1. **Create or pick a project**, eg. "NGU Website". 2. **APIs & Services → OAuth consent screen** (Google Auth Platform → Branding / Audience): - User type / audience: **Internal**. Only accounts in the Workspace can use it, and Google doesn't need to review the app. - App name: NGU Admin. Support email: yours. - Scopes: `openid`, `email`, `profile` (nothing else is needed). 3. **APIs & Services → Credentials → Create credentials → OAuth client ID** (Google Auth Platform → Clients): - Application type: **Web application**. Name: NGU admin. - Authorized redirect URIs: - `https://nextgenerationofunity.org/api/auth/google/callback` - for local work, also the dev address, eg. `http://localhost:5174/api/auth/google/callback` - No JavaScript origins are needed: the browser never talks to Google directly. 4. Copy the **Client ID** and **Client secret**. ## Turning it on On the server, add them to the `ngu-api` unit (`systemctl edit ngu-api`) and restart. Never commit the secret or paste it into the repo: ```ini [Service] Environment=GOOGLE_CLIENT_ID= Environment=GOOGLE_CLIENT_SECRET= ``` Optional: | Variable | Default | | --- | --- | | `GOOGLE_REDIRECT_URI` | `/api/auth/google/callback`. Set it for local work, eg. `http://localhost:5174/api/auth/google/callback`, and add the same URI in step 3. | | `GOOGLE_ALLOWED_DOMAIN` | `nextgenerationofunity.org` | The login page asks `/api/auth/providers` whether Google is set up, so the button appears as soon as the service restarts with both values. Locally, also set `COOKIE_SECURE=false` when working over plain http.