Can you explain how the OAuth 2.0 authorization code flow works and what the different grant types are?

Last updated 29 June 2026

  • Authorization code flow: the client redirects the user to the auth server, the user consents, and a one-time code is returned and exchanged server-side for an access_token (and optional refresh_token).

  • PKCE (a code_verifier/code_challenge pair) lets public clients like SPAs and mobile apps use the flow safely without a client secret.

  • Grant types: Authorization Code (recommended default), Client Credentials (machine-to-machine), and Refresh Token. Implicit and Password grants are deprecated.

  • https://www.freecodecamp.org/news/oauth-2-0-guide-for-backend-developers/
  • https://www.digitalocean.com/community/tutorials/an-introduction-to-oauth-2
  • https://medium.com/@meet2sudhakar/oauth-api-security-projects-interview-preparation-guide-cd87babeafa9
  • https://auth0.com/docs/get-started/authentication-and-authorization-flow/authorization-code-flow
  • https://auth0.com/docs/get-started/authentication-and-authorization-flow
  • https://auth0.com/docs/get-started/authentication-and-authorization-flow/authorization-code-flow-with-pkce
  • https://auth0.com/docs/get-started/authentication-and-authorization-flow/client-credentials-flow
  • https://auth0.com/docs/get-started/authentication-and-authorization-flow/device-authorization-flow
All REST API interview questions