Sign in with Google
FreeFlow@rabbinatix/sign-in-with-google by Rabbinatixupdated Oct 13, 2026
People sign in with their Google account: returning users get in, an existing account with the same email is linked, and new people get an account.
"Continue with Google", after Google sends the person back to your app:
- Client app passes on the code and state Google returned, and the state it saved before leaving.
- Auth service checks the state, swaps the code for the person’s Google id and email, and signs them in, links their existing account, or creates one.
- User store keeps the accounts and their Google id. Identity provider (Google, or any OpenID Connect provider) answers the code swap. Event bus (optional) receives
user.signed_up.
Tricky steps: the state must match what the app saved, or someone could sign a person into the attacker’s account. An account is linked by email only when Google has verified that email; otherwise anyone could claim it.
Previewlanes are roles; you pick your systems when importing
- No matches
Not foundNot found201400401403Other
Start in Client app. step 1 of 27. key stepOn Back from Google
Call to another system in Client app. step 2 of 27. key stepCall Google sign-in
Start in Auth service. step 3 of 27. key stepOn POST /api/v1/oauth/google/callback
Resource in Auth service. step 4 of 27. key stepSwap the code for who they are
Answer in Identity provider. step 5 of 27. key stepoauth.exchangeCode
Resource in Auth service. step 6 of 27. key stepSigned in with Google before?
Answer in User store. step 7 of 27. key stepusers.findByGoogleId
Return in Auth service. step 8 of 27. key stepReturning user → 200
Resource in Auth service. step 9 of 27An account with this email?
Answer in User store. step 10 of 27. key stepusers.findByEmail
Resource in Auth service. step 11 of 27Link Google to that account
Answer in User store. step 12 of 27. key stepusers.linkGoogle
Return in Auth service. step 13 of 27. key stepSame email → linked, 200
Resource in Auth service. step 14 of 27. key stepCreate the account
Answer in User store. step 15 of 27. key stepusers.insert
Resource in Auth service. step 16 of 27Publish user.signed_up
Answer in Event bus. step 17 of 27. key stepuser.signed_up
Return in Auth service. step 18 of 27. key stepNew account → 201
Return in Auth service. step 19 of 27. key stepUnverified email → 403
Return in Auth service. step 20 of 27. key stepUsed or expired code → 401
Return in Auth service. step 21 of 27. key stepWrong state → 400
Return in Client app. step 22 of 27. key stepReturn
Return in Client app. step 23 of 27. key stepReturn
Return in Client app. step 24 of 27. key stepReturn
Return in Client app. step 25 of 27. key stepReturn
Return in Client app. step 26 of 27. key stepReturn
Return in Client app. step 27 of 27. key stepReturn
Client app
Web frontend
Auth service
Backend service
User store
Database
Identity provider
External API
Event bus
Queue / event bus
Up and down arrows: previous or next step. Home, End: first or last. Enter: select. Shift F10: more actions.
APIs
POST{base}/oauth/google/callback· Finish signing in with Google
Auth service provides it · Client app calls it
Request body
code: string state: string expectedState: string
200
accessToken: string
201
accessToken: string
400
error: string
401
error: string
403
error: string
Data operations
oauth.exchangeCodecallon Identity provider(code: string)
users.findByGoogleIdqueryon User store(googleSub: string)
users.findByEmailqueryon User store(email: string)
users.linkGoogleupdateon User store(id: string, googleSub: string)
users.insertinserton User store(email: string, name: string, googleSub: string)
user.signed_uppublishon Event bus(userId: string)
Test cases
Returning Google user→ Signed in
Same email as a password account: linked→ Signed in to the existing account
New person gets an account→ New account
State doesn’t match→ Forged or stale sign-in refused
Code used or expired→ Code too old
Email not verified by Google is never linked→ Unverified email refused
A new account publishes user.signed_up→ New accountwith “Publish user.signed_up”
Requirements
A sign-in finishes only when its state matches the one the app started with.
An existing account is linked by email only when Google has verified that email.
One person, one account: a returning user is never given a second one.
Roles (5)
Client app
Where "Continue with Google" is, and where Google sends the person back · Web frontend or mobile app
Auth service
Swaps the code and signs the person in · Backend service
User store
Database with the accounts · Database
Identity provider
Google, or another OpenID Connect provider · External API
Event bus (optional)
Receives user.signed_up (optional) · Queue / event bus
Settings
Publish user.signed_upon
Email fieldemail (renamable)
Also as a whiteboard
Fits these system maps
Versions
