Documentation Index
Fetch the complete documentation index at: https://mintlify.com/JuanSebasSV/healtyhelp/llms.txt
Use this file to discover all available pages before exploring further.
Overview
HealtyHelp integrates Google OAuth 2.0 via Passport.js (passport-google-oauth20). Users can sign in with their Google account without creating a password. The server exchanges the Google authorization code for a user profile, finds or creates the matching HealtyHelp account, mints a JWT, and redirects the browser back to the frontend.
The OAuth Flow
Endpoints
| Method | Path | Description |
|---|---|---|
GET | /api/auth/google | Initiates the OAuth flow; redirects the browser to Google’s consent screen |
GET | /api/auth/google/callback | Google redirects here after user consents; issues JWT and redirects to frontend |
Callback redirect format
After a successful login the server issues a302 redirect to:
Passport strategy configuration
- Existing Google account (
googleIdmatch) — updates the user’s avatar with Google’s latest photo and returns the user. - Existing email/password account — links the Google identity to the existing account, marks it as verified, and updates the avatar.
- New user — creates a fresh account with
isVerified: true(no email verification required).
Account Linking
If a user previously registered with email/password using the same email address as their Google account, HealtyHelp automatically links both identities on the first Google sign-in:googleIdis added to the existing user document.isVerifiedis set totrue(if it wasn’t already).- The Google profile photo becomes the user’s avatar.
If a user tries to register with email/password using an email already associated with a Google-only account, they receive an error directing them to use the “Continue with Google” button.
Setting Up Google Cloud Console
Create a Google Cloud project
Go to console.cloud.google.com and create a new project (or select an existing one).
Enable the Google+ / People API
In the project dashboard, navigate to APIs & Services → Library. Search for “Google People API” and click Enable.
Configure the OAuth consent screen
Go to APIs & Services → OAuth consent screen. Choose External and fill in the required fields:
- App name — e.g.
HealtyHelp - User support email — your support address
- Authorized domains — your production domain (e.g.
healthyhelpoficial.com)
email and profile, then save.Create OAuth 2.0 credentials
Go to APIs & Services → Credentials → Create Credentials → OAuth client ID. Select Web application and fill in:
- Name — e.g.
HealtyHelp Web - Authorized JavaScript origins
- Authorized redirect URIs (must match
callbackURLinpassport.jsexactly):
Required Environment Variables
| Variable | Description |
|---|---|
GOOGLE_CLIENT_ID | OAuth 2.0 Client ID from Google Cloud Console |
GOOGLE_CLIENT_SECRET | OAuth 2.0 Client Secret from Google Cloud Console |
BACKEND_URL | Full URL of the HealtyHelp API (e.g. https://api.healthyhelpoficial.com) |
FRONTEND_URL | Full URL of the frontend app (e.g. https://healthyhelpoficial.com) |
The GoogleCallback Component
On the frontend, the /google-callback route is handled by the GoogleCallback React component. It:
- Reads the
tokenquery parameter from the URL. - Stores the token in
localStorage. - Calls
GET /api/auth/meto fetch the current user. - If the user is a Google-only account (
googleIdset,hasPassword === false), displays the ModalGooglePassword instead of navigating home. - Otherwise, calls
checkAuth()and redirects to/.
Adding a Password to a Google Account (ModalGooglePassword)
Google-only users can optionally set a password so they can also log in with email/password. This is surfaced automatically in the ModalGooglePassword component immediately after their first Google sign-in.
Endpoint:
- The account must have a
googleId(Google-only accounts only). - The account must not already have a password set.