How an OAuth login works

How an OAuth login works, as an animated sequence diagram: the user, the app and the identity provider exchanging redirects, codes and tokens, one message at a time.

animated sequence diagram Open in the editor

Step by step

  1. Four parties take part
  2. The user wants to sign in
  3. The app sends them to Google
  4. Google asks for permission
  5. Google returns a one-time code
  6. The app calls the API with a token
  7. And the user is in

Make one like this

Three ways, all free. No account needed.

In the editor

Open this diagram in the editor and change the text, the blocks or the order of the steps. Export it as a GIF or an HTML page.

Open in the editor →

With your AI agent

Install the Fluxygram skill in Claude, Cursor, Codex or Gemini and ask for it in plain words:

Use the Fluxygram skill to make an animated diagram: How an OAuth login works.
How to install the skill →

On your site

Download the JSON and show it anywhere with one script:

<script type="module" src="https://cdn.jsdelivr.net/npm/fluxygram@0.3"></script>
<fluxy-gram src="sequence.flux.json"></fluxy-gram>
Download the JSON →
See the JSON behind this diagram
{
  "$schema": "/schema/v1.json",
  "type": "sequence",
  "title": "How an OAuth login works",
  "nodes": [
    {
      "id": "user",
      "label": "User",
      "icon": "user"
    },
    {
      "id": "app",
      "label": "Your app",
      "icon": "browser"
    },
    {
      "id": "google",
      "label": "Google",
      "icon": "shield"
    },
    {
      "id": "api",
      "label": "API",
      "icon": "server"
    }
  ],
  "edges": [
    {
      "id": "m1",
      "from": "user",
      "to": "app",
      "label": "click Login"
    },
    {
      "id": "m2",
      "from": "app",
      "to": "google",
      "label": "redirect"
    },
    {
      "id": "m3",
      "from": "google",
      "to": "user",
      "label": "asks for consent"
    },
    {
      "id": "m4",
      "from": "google",
      "to": "app",
      "label": "code",
      "carries": "code"
    },
    {
      "id": "m5",
      "from": "app",
      "to": "api",
      "label": "request + token",
      "carries": "token"
    },
    {
      "id": "m6",
      "from": "api",
      "to": "app",
      "label": "user data"
    }
  ],
  "steps": [
    {
      "show": [
        "user",
        "app",
        "google",
        "api"
      ],
      "caption": "Four parties take part"
    },
    {
      "show": [
        "m1"
      ],
      "flow": "m1",
      "caption": "The user wants to sign in"
    },
    {
      "show": [
        "m2"
      ],
      "flow": "m2",
      "caption": "The app sends them to Google"
    },
    {
      "show": [
        "m3"
      ],
      "flow": "m3",
      "state": {
        "google": "pending"
      },
      "caption": "Google asks for permission"
    },
    {
      "show": [
        "m4"
      ],
      "flow": "m4",
      "state": {
        "google": "success"
      },
      "caption": "Google returns a one-time code"
    },
    {
      "show": [
        "m5"
      ],
      "flow": "m5",
      "caption": "The app calls the API with a token"
    },
    {
      "show": [
        "m6"
      ],
      "flow": "m6",
      "state": {
        "app": "success"
      },
      "caption": "And the user is in"
    }
  ]
}

More examples

See all examples →