Skip to the content.

A grant type simply answers:

β€œHow is the client proving who the user is to get an access token?”

Different situations β†’ different grant types.


🧠 First, the actors


βœ… 1. Authorization Code Grant (Most Important)

Used when:

User logs in via browser (Angular / React / Web app)

Flow:

  1. User redirected to Auth Server login page
  2. User logs in
  3. Auth server sends code to client
  4. Client exchanges code for access token

Why this exists?

So that password never touches the client app

Today’s standard:

πŸ‘‰ Authorization Code + PKCE (mandatory for SPA)

Best for Web apps, SPA, Mobile
User present βœ…
Secure βœ… Most secure
Recommended ⭐⭐⭐⭐⭐

βœ… 2. Client Credentials Grant

Used when:

Machine-to-Machine communication

No user.

Example:

Order Service β†’ Payment Service

Flow:

Client sends:

client_id + client_secret

Gets access token.

Best for Microservice calls
User involved ❌
Secure βœ…
Recommended ⭐⭐⭐⭐⭐

You will use this a LOT in microservices.


βœ… 3. Refresh Token Grant

Not for login.

Used to:

Get new access token without asking user to login again

Best for Keeping user logged in
User involved ❌
Works with Authorization Code

⚠️ 4. Implicit Grant (Deprecated)

Old way for SPA before PKCE existed.

Problems:

❌ Do not use in 2026

Replaced by:

Authorization Code + PKCE


⚠️ 5. Resource Owner Password Credentials (ROPC) (Deprecated)

Used when:

Client asks user:

β€œEnter username & password here”

Then sends password to auth server.

This is what basic login forms used to do.

Problems:

❌ Not recommended anymore


🧩 6. Device Code Grant

Used when:

Device has no browser

Example:

Flow: TV shows code β†’ user enters on phone β†’ TV gets token.

Best for TV, CLI, IoT
User present βœ… (on another device)

πŸ† 7. PKCE (Enhancement, not a grant)

PKCE = extra security layer for Authorization Code.

Mandatory for:

Prevents code interception attacks.


πŸ“Š Quick Comparison

Grant Type User Login Where Used Status
Authorization Code + PKCE βœ… Web, SPA, Mobile ⭐ Best
Client Credentials ❌ Microservices ⭐ Best
Refresh Token ❌ Session renewal ⭐
Device Code βœ… TV / CLI ⭐
Implicit βœ… Old SPA ❌ Deprecated
Password (ROPC) βœ… Old apps ❌ Deprecated

🧠 Real World Mapping (your kind of backend system)

Scenario Grant
Angular app login Authorization Code + PKCE
Service to service call Client Credentials
Keep user logged in Refresh Token
CLI tool login Device Code

One-liner memory trick

User in browser? β†’ Auth Code No user? β†’ Client Credentials Need new token? β†’ Refresh No browser? β†’ Device Code


Grant Type (Actual grant_type value) Common Name User Involved Typical Use Case Status / Notes
authorization_code Authorization Code βœ… Yes Web apps, SPA, Mobile apps (with PKCE) ⭐ Recommended standard
client_credentials Client Credentials ❌ No Service-to-service / microservices ⭐ Recommended
refresh_token Refresh Token ❌ No Get new access token without login ⭐ Used with auth code
urn:ietf:params:oauth:grant-type:device_code Device Code βœ… Yes (on another device) TV, CLI tools, IoT devices ⭐ Recommended for devices
password Resource Owner Password Credentials (ROPC) βœ… Yes Legacy apps asking username/password directly ❌ Deprecated / avoid
implicit Implicit Grant βœ… Yes Old browser-based apps ❌ Deprecated / removed from best practices

Example Token Requests

Authorization Code

grant_type=authorization_code

Client Credentials

grant_type=client_credentials

Refresh Token

grant_type=refresh_token

Device Code

grant_type=urn:ietf:params:oauth:grant-type:device_code

Password (deprecated)

grant_type=password