What it does
Your app can offer Sign in with Google without registering its own Google OAuth client. HandCash owns the Google/Auth0 integration and returns a login URL. Once Google authenticates the user, HandCash Connect authorizes your app and returns to the success URL registered in the Developer Dashboard. Your app never receives a Google authorization code, access token, refresh token, client ID, or client secret.This is a convenience entry point into the standard
Connect authentication flow — it produces a
HandCash Connect authorization and does not grant your app access to the
user’s Google account.
Flow
Prerequisites
- Create a HandCash Connect app in the Developer Dashboard.
- Set its authentication success URL to
https://<your-host>/auth/callback. - Configure your backend:
https://preprod-market.handcash.io only with matching preproduction app
credentials.
Start the flow
On your backend:- Create a cryptographically random, single-use CSRF value.
- Create a one-time secp256k1 key pair.
- Store the private key and CSRF record in
HttpOnly,SameSite=Laxcookies. UseSecureoutside local HTTP development and expire both within 10–30 minutes. - Build this proxy-relative return path:
authUrl to browser JavaScript. Never return the temporary private key.
Open the login URL
OpenauthUrl in a popup on desktop. On mobile—or when popup creation is
blocked—use a top-level navigation.
The proxy selects Auth0’s google-oauth2 connection and resumes /connect
after login. autoAuthorize=true removes an unnecessary second click when
policy permits it; it does not bypass Connect consent, signing-key, or 2FA
requirements.
Complete your callback
AtGET /api/auth/callback on your origin:
- Compare returned
stateto the short-lived CSRF cookie. Fail closed on a missing, expired, reused, or mismatched value. - Require the temporary private-key cookie.
- Validate the Connect authorization by loading the current user profile with
HANDCASH_APP_ID,HANDCASH_APP_SECRET, and the temporary private key. - Establish your application session.
- Delete the temporary key and CSRF cookies.
Endpoint distinction
Applications must call the
/app endpoint.
Common failures
Reference implementation
Soundbase is the app-side reference:app/api/auth/google/route.ts— start;app/api/auth/callback/route.ts— validate and establish the session;contexts/auth-context.tsx— popup and mobile fallback;lib/auth-utils.ts— ephemeral key generation.
src/app/api/auth/google/app/route.ts.
Security requirements
- The proxy validates
returnToagainst its own origin. - Your app binds one state and one ephemeral key to one short-lived flow.
- The private key never appears in a URL or client-readable storage.
- Your callback validates the Connect credential before issuing a session.
- The proxy never forwards Google tokens to your app.
- Popup completion checks
event.origin; popup closure alone is not proof of successful login.