Runbook: Email Pull OAuth App Swap
This runbook covers the transition of the Email Pull feature from the legacy gog-cli OAuth app to the CASA-verified Ordermatic OAuth app.
Overview
Section titled βOverviewβThe gog-cli OAuth app was used during initial development and Phase 1. As we move to Phase 1.5, we must swap to the official Ordermatic app which has undergone CASA (Cloud App Security Assessment) verification.
Critical Note: Refresh tokens are bound to the OAuth app that issued them. Swapping the client_id and client_secret will invalidate all existing customer connections. Customers MUST reconnect their mailboxes to resume polling.
Phase 1: Pre-Swap Notification (Window: T-48h)
Section titled βPhase 1: Pre-Swap Notification (Window: T-48h)β- Identify Affected Customers:
Query the database for all active email pull connections:
SELECT DISTINCT clerk_organization_id, email_address, providerFROM email_pull_connectionsWHERE status = 'active';
- Send Notification:
Email affected customers/admins notifying them of the scheduled maintenance window.
- Subject: [Action Required] Reconnect your Email Ingestion mailbox
- Content: We are upgrading our security infrastructure. Your email connection will be paused on [Date/Time]. You will need to click βReconnectβ in the Settings -> Email Connections menu to resume order ingestion.
Phase 2: Swap Window
Section titled βPhase 2: Swap Windowβ-
Update Secrets in Infisical: Update the following secrets in the
webappandtemporal-workerenvironments (Staging and Production):GOOGLE_OAUTH_CLIENT_IDGOOGLE_OAUTH_CLIENT_SECRETMICROSOFT_OAUTH_CLIENT_IDMICROSOFT_OAUTH_CLIENT_SECRET
These should now point to the Ordermatic CASA-verified app credentials.
-
Verify Secret Deployment: Trigger a deployment or restart of the
webappandtemporal-workerto ensure they pick up the new secrets.
Phase 3: Post-Swap Verification
Section titled βPhase 3: Post-Swap Verificationβ-
Monitor Failures: Monitor the
email_pull.poll.failurecounter in Grafana/Betterstack.- Expected Behavior: A spike in
auth_revokedorinvalid_granterrors for all existing connections. - Recovery: Errors should decrease as customers reconnect.
- Expected Behavior: A spike in
-
Support Reconnection: Customers will see a βDisconnectedβ or βErrorβ status in the UI. They should click the βReconnectβ button (implemented in ENG-504) to initiate a new OAuth flow with the Ordermatic app.
-
Validate New Connections: Ensure new connections are successfully issuing tokens from the new app.
SELECT id, email_address, status, last_error, updated_atFROM email_pull_connectionsORDER BY updated_at DESC LIMIT 10;
Rollback Plan
Section titled βRollback PlanβIf critical issues occur (e.g., the new app is not accepting tokens):
- Revert the Infisical secrets to the
gog-clicredentials. - Notify customers that the upgrade has been postponed and they should reconnect if they already did.