Antonio Braccolino, Identity & Access, home
EN · Language: English
← All terms

IAM glossary

What is Authorization Code flow?

The standard OAuth flow for users: the browser gets a short-lived code, the app exchanges it for tokens on a direct call. With PKCE it is the right choice for web, mobile and single-page apps.

How it works

The app redirects the browser to the authorization server with response_type=code, its client_id, a redirect_uri, the scopes and a random state. The user signs in and consents. The server redirects back to the app with a short-lived code in the URL.

The app then calls the token endpoint directly (not through the browser), sending the code and proving who it is (client secret or, for public apps, the PKCE verifier). Only then does it receive the access token, the refresh token and, with OIDC, the ID token. Tokens never travel in the browser URL.

A simple example

You click “Sign in with Google” on a recipe site. The browser goes to Google, you sign in, and Google sends you back to recipes.example/callback?code=4/0Ab...&state=xyz. The recipe site’s server exchanges that code with Google for tokens in a few milliseconds. The code is useless to anyone who copies it later: it expires in seconds and works only once.

Common mistakes

  • Not checking state on the way back, which opens the door to login CSRF.
  • Skipping PKCE in mobile and single-page apps, where a client secret cannot be kept.
  • Accepting any redirect_uri instead of an exact, pre-registered one.

See it at work

Related terms