Google OAuth verification & Gmail connect setup
This product uses Google OAuth so buyers click Sign in with Google and see Google’s consent screen (send mail, read mail for replies). Without GOOGLE_CLIENT_ID / GOOGLE_CLIENT_SECRET in mail_saas.env, no Google screen appears — configure credentials first, then restart the app.
1. Create a Google Cloud project
- Open Google Cloud Console.
- Create a project (e.g.
nexus-mail-saas). - Enable Gmail API and Google People API (or userinfo).
2. OAuth consent screen
- APIs & Services → OAuth consent screen.
- User type: External (for public buyers).
- App name, support email, developer contact.
- Scopes to add:
-
https://www.googleapis.com/auth/gmail.send-https://www.googleapis.com/auth/gmail.readonly-openid-userinfo.email - While unverified, add test users (their Google accounts can connect).
3. Create OAuth client
- Credentials → Create credentials → OAuth client ID.
- Application type: Web application.
- Authorized redirect URI (must match env):
https://YOUR_DOMAIN/api/mailbox/oauth/callback
Local example:
http://127.0.0.1:8090/api/mailbox/oauth/callback
- Copy Client ID and Client secret into
mail_saas.env:
GOOGLE_CLIENT_ID=....apps.googleusercontent.com
GOOGLE_CLIENT_SECRET=....
MAIL_SAAS_BASE_URL=https://YOUR_DOMAIN
4. Verification (production)
Gmail send/readonly are restricted scopes. Before public launch:
- Complete the OAuth verification questionnaire.
- Provide a privacy policy URL (use
https://YOUR_DOMAIN/privacyfrom this app) and demo video of connect → send. - Set
MAIL_SAAS_CONTACT_EMAILinmail_saas.envso the policy shows a real support address. - Expect Google review time (days–weeks). Stay in Testing mode with allowlisted users until approved.
- Do not request unused scopes — keep the list minimal.
5. Security notes for reviewers
- Refresh tokens are encrypted at rest (
MAIL_SAAS_SECRET_KEY). - One mailbox per user; From address is forced to the connected account (sender lock).
- One concurrent session per subscription seat (license lock).
- Users can disconnect mailbox anytime.
6. Stripe Customer Portal
- Stripe Dashboard → Settings → Billing → Customer portal (enable cancel/update).
- Set
STRIPE_SECRET_KEY,STRIPE_PRICE_ID(quantity 1),STRIPE_WEBHOOK_SECRET. - Webhook endpoint:
https://YOUR_DOMAIN/api/stripe/webhookEvents:checkout.session.completed,customer.subscription.updated,customer.subscription.deleted.