Sign in with Google sequence diagram (OAuth)

This sequence diagram shows how "Sign in with Google" works between the **User**, your **App**, **Google** and your **Backend**. The key idea is that the app receives an **ID token** from Google, and the backend verifies it before creating a session. It suits developers adding Google sign-in and anyone explaining OAuth and OpenID Connect.

Sequence diagram for Sign in with Google

Example: Sequence diagram for Sign in with Google: click to open it in the editor and change it.

The messages in order

  1. User → App: Click "Sign in with Google".
  2. App → Google: Open the consent screen.
  3. User → Google: Approve.
  4. Google → App: ID token.
  5. App → Backend: Verify the ID token.
  6. Backend → Google: Check the token.
  7. Google → Backend: Valid.
  8. Backend → App: Session.

Why the backend verifies the token

The app could read the ID token itself, but a token from the browser can't be trusted on its own. The Backend checks it with Google, confirming the signature and that it was issued for your app, before it creates the user's session.

How to adapt it for your app

  • Add a new user? alt box where the backend creates the account on first sign-in.
  • Verify the token locally with Google's public keys instead of a call to Google, which saves a round trip.
  • Add the cookie or token the backend returns, and later requests that use it.

Tip: Always check that the token's audience matches your own client ID, so tokens issued to other apps are rejected.

Frequently asked questions

Is Sign in with Google OAuth or OpenID Connect?

Both: OpenID Connect is built on OAuth 2.0 and adds the ID token that tells your app who the user is.

What is the ID token?

A signed token from Google with the user's identity, such as their email and a unique ID. Your backend verifies it before trusting it.

Why does the backend talk to Google too?

To confirm the token is genuine and meant for your app. A token sent from the browser alone could be forged.

Make your own sequence diagram with AI →

More templates

← All templates

Try AI Flowchart free →