GalleryExamplesDraw your repo

Examples / Sequence diagrams

OAuth login with PKCE

How a single-page app signs a user in with OAuth 2.0 authorization code and PKCE, from the login button to a stored access token.

OAuth login with PKCE: sequence diagram of Browser, React SPA, Authorization server and App API▶ Play the story
Open in Plotix A copy you can edit, or ask the agent to change.
Plotix's agent drew it from this request

Draw a sequence diagram of a React single-page app signing a user in with OAuth 2.0 authorization code flow with PKCE: browser, SPA, authorization server, the app's API. Include the code verifier, redirect, token exchange and the first API call.

Step by step: PKCE sign-in

  1. The user clicks Sign in. The SPA creates a code_verifier and derives its code_challenge.
  2. The SPA sends the browser to the authorization server with the code_challenge and a state value.
  3. The browser requests /authorize with the code_challenge and state.
  4. The authorization server shows its login and consent page.
  5. The user signs in and approves consent.
  6. The authorization server redirects the browser back with a one-time code and the state.
  7. The browser loads the /callback route in the SPA with the code and state. The SPA checks the state.
  8. The SPA posts the code and the code_verifier to the token endpoint.
  9. The authorization server checks the verifier against the challenge and returns the tokens.
  10. The SPA makes its first API call with the access token as a Bearer token.
  11. The API validates the token and returns the user profile. The user is signed in.
What's in it
OAuth login with PKCE: sequence diagram of Browser, React SPA, Authorization server and App API

How the parts connect

More on sequence diagrams.

Related examples

Stripe checkout and webhook: flow diagram of Shopper starts checkout, Create Checkout Session, Redirect shopper to Stripe, Payment succeeds?, Card declined or error and 5 more
Stripe checkout and webhookFlow · The steps from a cart to a paid order with Stripe Checkout, including the webhook that co…
Serverless API on AWS: deployment diagram of CloudFront, API Gateway, Lambda functions, Cognito user pool, CloudWatch Logs and 4 more
Serverless API on AWSDeployment · Where a serverless web API runs on AWS: CloudFront and S3 for the site, API Gateway and L…
Web app on Kubernetes: deployment diagram of Users, Ingress controller, Web deployment, Worker deployment, Cron job and 5 more
Web app on KubernetesDeployment · A typical web app deployed on Kubernetes: ingress, web and worker deployments, a managed…