Setting up Sign in with Google
For IT teams - create the Google client ID in about ten minutes, connect it to Presence, and the security checks that protect every Google sign-in.
4 min read
Sign in with Google uses Google Identity Services with the ID-token flow - the simplest and safest option for a web app like Presence:
- Google shows its own button and window; the person signs in with Google, not with Presence.
- Google returns a signed ID token to the app, which passes it to the Presence server.
- The server checks Google’s signature and the token’s details before signing the person in.
- Only one public value is needed: the client ID. There is no client secret to store or leak, and Presence never receives a Google password or access to anyone’s Gmail or Drive.
On the Animweb-hosted service, Animweb Technologies does this setup. On your own domain, your IT team does it once, in about ten minutes.
1. Create the Google client ID
-
Open the Google Cloud console with an account your institution controls, and create a project, for example Presence sign-in.
-
Open Google Auth Platform (formerly OAuth consent screen) and complete Branding:
- App name: your institution’s name with Presence, for example Riverbend Presence.
- User support email and developer contact: your IT team’s address.
- Authorised domains: your domain, for example
your-university.edu.
-
Under Audience, choose:
- Internal if everyone signs in with your own Google Workspace accounts - only your domain’s accounts can then use it at all;
- External otherwise, then Publish app so it is In production.
-
Under Data access, add no extra scopes. Presence needs only the basic
openid,emailandprofile, which need no Google review. -
Under Clients, choose Create client → Web application and add Authorised JavaScript origins:
- your Presence app address, for example
https://attendance.your-university.edu; - for local testing only:
http://localhostandhttp://localhost:4173.
No redirect URIs are needed: the sign-in runs in Google’s pop-up window.
- your Presence app address, for example
-
Copy the Client ID (it ends in
.apps.googleusercontent.com).
Google accepts only real domains and
localhostas origins - not network addresses such as192.168.1.34. To try Google sign-in on phones before go-live, use your real domain with HTTPS.
2. Connect it to Presence
- On the Presence API server, set the environment variable
GOOGLE_CLIENT_IDto the client ID (on Railway: Variables), then restart or redeploy the API. - Nothing changes in the app build: it reads the client ID from the server when the sign-in page opens.
- The app’s security headers already allow Google’s sign-in script and window (
accounts.google.com/gsi/), and only those paths.
3. Turn it on for the institution
An administrator opens Settings → Sign in with Google, turns on Allow Sign in with Google, and optionally limits it to your email domains. Each person’s email in Users must match the Google account they will use. See Signing in & signing out.
4. Test it
| Test | Expected result |
|---|---|
| Sign in with a Google account whose email is on a Presence account | Signed in; the audit log shows Google sign-in and Google account linked |
| Sign in with a Google account that has no Presence account | Refused: No account at … uses … |
| With a domain set, sign in with a personal Gmail address | Refused: Use your @your-university.edu Google account |
| An account with two-factor turned on | Asks for the 6-digit code after Google |
| Sign out, then open the sign-in page again | Google does not sign you in automatically |
The security checks on every Google sign-in
The Presence server accepts a Google sign-in only when all of these hold:
| Check | Why |
|---|---|
| The token is signed with RS256 by one of Google’s current keys (fetched from Google and cached as Google allows) | Nobody but Google can produce it |
| The audience is your client ID | A token issued to another app cannot be used here |
The issuer is accounts.google.com and the token has not expired |
Old or foreign tokens are refused |
| The token carries a single-use nonce that the server issued minutes earlier | A captured token cannot be replayed |
| The email is verified by Google | Unverified addresses are refused |
| The institution has turned Google sign-in on, and the email’s domain is allowed | Each institution decides for itself |
| An existing, active account uses that email | Google never creates accounts |
| The account’s linked Google account (Google’s permanent user ID) matches | A reused or reassigned email cannot take over an account |
| Two-factor, if the person has it | Google proves the email; the authenticator proves the person |
Sign-ins, new links, refused links and two-factor recovery are written to the audit log. Sessions after a Google sign-in are the same short, single-use-renewal sessions as after a password sign-in, and signing out also stops Google from choosing the account automatically next time.
Good practice
- Use Internal audience, or set your email domains in Presence, so only college accounts are accepted.
- Keep two-factor on for administrators, deans, heads and office staff - with or without Google.
- Keep the Google Cloud project owned by an institutional account, not one person’s, and give at least two IT staff access.
- If a client ID is ever replaced, update
GOOGLE_CLIENT_IDand restart the API; nobody needs to do anything else.