Card 10/ 11

ExerciseDifficulty: Advanced1 min

Practice: The Right Flow for Four Applications

A single-page app, a mobile app, a nightly billing job and a server-rendered website.

Choosing an OAuth flow means asking whether a user is involved and whether the client can keep a secret. For each application, choose the grant, say which tokens it receives, and give the reason.

  1. A single-page app in the browser that shows a user's calendar from a calendar API.
  2. A mobile app that lets a user sign in with an identity provider and posts to their account.
  3. A nightly job that reads every account's usage from a billing API.
  4. A server-rendered website that signs users in and calls an API for them.
Show the answers
Each application, its grant, its tokens, and the reason
ApplicationGrantTokensReason
Single-page appAuthorization code with PKCEAccess token, refresh token with rotationA user is involved; a public client cannot hold a secret; implicit is retired
Mobile appAuthorization code with PKCE, plus the openid scopeAccess, ID and refresh tokensA user signs in; the system browser handles login, per RFC 8252
Nightly billing jobClient credentialsAccess token onlyNo user; the job acts for itself
Server-rendered websiteAuthorization code with PKCE and a client secret, plus openidAccess, ID and refresh tokens, kept on the serverA confidential client still uses PKCE