Direct Access Grants Flow in Keycloak, Explained From Zero

Direct Access Grants Flow in Keycloak, Explained From Zero

A complete, beginner-friendly walkthrough of how Keycloak's Direct Access Grants (Resource Owner Password Credentials) flow works, why it exists, where it fits among OAuth 2.0 flows, and when you should — and should not — use it.

Imagine you walk up to a hotel’s front desk and, instead of the receptionist checking you in and handing you a room key, you hand your ID and passport directly to the security office yourself, and they hand you the key card on the spot — no receptionist in between. That is roughly what the Direct Access Grants flow does in the world of identity and access management: an application collects a user’s username and password itself, sends them straight to Keycloak, and gets back a token in return. No browser redirects, no login screens hosted by Keycloak, no middleman. It sounds convenient, and it is — but like skipping the front desk, it also comes with trade-offs you need to understand before you rely on it. This tutorial walks through the entire flow from first principles, so that even if you have never touched Keycloak or OAuth 2.0 before, you will finish with a solid, practical understanding of what Direct Access Grants is, how it works internally, and how to use it responsibly.

1What Is Keycloak, and What Problem Does It Solve?

Before we can talk about Direct Access Grants, we need to understand the system it lives inside.

The problem: every app needs to know who you are

Almost every piece of software you use — a banking app, an online store, an internal company dashboard — needs to answer one question before it does anything else: “who is this person, and what are they allowed to do?” This is called authentication (proving who you are) and authorization (deciding what you’re allowed to do). If every single application had to build its own username/password database, its own password reset flow, its own multi-factor authentication, and its own session management, we would end up with hundreds of slightly different, slightly insecure login systems scattered across a company.

Simple Analogy

Think of a large office building with dozens of companies renting floors. Instead of every company installing its own front door, ID scanner, and security guard, the building has one central security desk on the ground floor. You show your ID once at that desk, and it issues you a badge that every floor in the building trusts. Keycloak is that central security desk — one identity system that many applications (“floors”) can trust instead of each building its own.

What Keycloak actually is

Keycloak is an open-source Identity and Access Management (IAM) system, originally built by Red Hat and now part of the Cloud Native Computing Foundation ecosystem. It centralizes login, user storage, password policies, multi-factor authentication, and token issuance in one place, so individual applications don’t have to reinvent any of it. Instead of writing your own login form and password database, your application simply asks Keycloak, “has this person logged in, and here is proof” — and Keycloak hands back a signed, verifiable token.

Realm

Isolated tenant

A self-contained space in Keycloak with its own users, clients, and settings — like a separate building on the same street.

Client

An application

Any app (web, mobile, backend service) registered with Keycloak so it can request tokens on a user’s behalf.

User

A real person or service

An identity stored in Keycloak (or federated from LDAP/Active Directory) that can log in and be granted roles.

Token

Proof of identity

A signed piece of data (usually a JWT) that other systems can verify without calling Keycloak every single time.

Why “flows” exist at all

OAuth 2.0, the protocol Keycloak implements, doesn’t define just one way to get a token — it defines several, called grant types or flows. Each flow is designed for a different situation: a flow suitable for a website with a browser is very different from one suitable for a smart TV with no keyboard, which is again different from one suitable for a backend job with no human user at all. Direct Access Grants is one of these flows, purpose-built for a specific, narrower situation than the others — and understanding that situation is the whole point of this tutorial.

2What Exactly Is the Direct Access Grants Flow?

Now that we know Keycloak’s role, let’s define the flow itself in plain terms.

In Keycloak’s admin console, “Direct Access Grants” is the friendly name for what the OAuth 2.0 specification calls the Resource Owner Password Credentials (ROPC) grant. Stripped of jargon, it means this: the application itself collects the user’s username and password (usually through its own login form) and sends those credentials directly to Keycloak’s token endpoint. Keycloak checks them and, if they’re correct, returns tokens immediately in the same response — no redirects, no separate Keycloak-hosted login page, no browser pop-up.

!
Important Distinction

“Resource Owner” is OAuth terminology for the end user — the person who owns the data or account being accessed. “Direct Access Grants” is simply Keycloak’s more approachable name for the same concept.

The core idea in one sentence

Instead of Keycloak showing the login screen, your own application shows the login screen, collects the password, and forwards it to Keycloak on the user’s behalf in a single, direct HTTP request.

Simple Analogy

Going back to the office building security desk: normally, you walk to the desk yourself, show your ID, and get your badge (that’s the usual redirect-based login). With Direct Access Grants, it’s as if you handed your ID to a trusted colleague standing at your company’s own door, and that colleague ran it down to the security desk for you and brought your badge back up. It’s faster and skips a trip — but it only works if you deeply trust that colleague, because they physically held your ID for a moment.

Where it lives in the Keycloak admin console

For any client registered in Keycloak, under the client’s Settings tab there is a toggle called “Direct Access Grants Enabled.” When this is switched on, that client is permitted to use this flow. By default, many client templates leave it enabled, which is one reason it’s important to consciously decide whether your client actually needs it, rather than leaving it on by accident.

Typical shape of the request

The application sends a request to Keycloak’s token endpoint containing the grant type (indicating “password” grant), the client’s identifier, the client secret (for confidential clients), and the user’s username and password. Keycloak validates all of this in one step and responds with tokens if everything checks out.

We are deliberately not including raw request/response code samples in this tutorial — the goal here is to build a strong mental model of what happens and why, not to hand you copy-paste snippets. Once the concepts below are clear, reading Keycloak’s official request/response reference will make immediate sense.

3Where Direct Access Grants Fits Among OAuth 2.0 Flows

Context matters — seeing the whole family of flows helps you understand why this one is shaped the way it is.

OAuth 2.0 defines a small family of flows, and Keycloak implements all of the common ones. Each is optimized for a different combination of “who is present” (a human with a browser? a backend service? a device with no screen?) and “how much do we trust the application?”

Authorization Code

The standard web/mobile flow

User is redirected to a Keycloak-hosted login page; the app never sees the password. Considered the gold standard for apps with a browser.

Direct Access Grants

Password sent directly

App collects the password itself and exchanges it for a token in one direct call. No redirect, no Keycloak-hosted screen.

Client Credentials

No human involved

Used for service-to-service communication, where a backend system authenticates as itself, not on behalf of any user.

Device Authorization

For screenless devices

Used by smart TVs, CLI tools, or IoT devices: the user logs in on a separate phone/laptop while the device polls for a token.

The key differentiator: who touches the password

The single most important distinction between these flows is who ever sees the user’s raw password. In the Authorization Code flow, only Keycloak’s own login page ever sees it — the client application never does. In Direct Access Grants, the client application’s own form is what the user types their password into, meaning the application code has a brief window where it is directly handling raw credentials.

i
Why This Matters

Once the password touches your application’s code — even briefly, even without storing it — your application becomes part of the security boundary. If it’s compromised, logs the request body, or is running inside a browser where a malicious script could intercept form input, the password is exposed in a way it never would be with a redirect-based flow.

A quick map of the request flow difference

The diagram below shows, at a high level, how a browser-redirect flow (like Authorization Code) differs structurally from Direct Access Grants. Notice that in the redirect-based flow, the browser is sent away to Keycloak’s own domain to enter the password, whereas in Direct Access Grants, the password never leaves the application’s own form.

flowchart LR
    subgraph Redirect["Authorization Code Flow"]
        A1[User] -->|clicks Login| A2[App]
        A2 -->|redirect| A3[Keycloak Login Page]
        A3 -->|user types password here| A3
        A3 -->|redirect back with code| A2
    end
    subgraph Direct["Direct Access Grants Flow"]
        B1[User] -->|types password into| B2[App's own form]
        B2 -->|sends username+password| B3[Keycloak Token Endpoint]
        B3 -->|returns tokens| B2
    end
        
FIG 1 — Structural difference: where the password is typed determines who is trusted with it.

This single structural difference — where the password gets typed — is the reason the two flows have such different security postures, and it’s why OAuth 2.0’s later security guidance treats them so differently, as we’ll cover in the security chapter.

4Step-by-Step: How the Flow Actually Works

Let’s walk through the full lifecycle of a single login using Direct Access Grants, from the moment a user types their password to the moment the app has a usable token.

1

User enters credentials in the app’s own UI

The user is looking at a login form built and hosted by the application itself — not by Keycloak. They type their username and password directly into it, exactly as they would with any traditional login form.

2

App sends a token request to Keycloak

The application makes a server-to-server (or client-to-server) request to Keycloak’s token endpoint, specifying the “password” grant type, along with the client’s own identifier, its secret (if it’s a confidential client), and the user’s username and password.

3

Keycloak authenticates the client

Before even looking at the user’s credentials, Keycloak first checks that the requesting client itself is who it claims to be — verifying its client ID and secret. If this fails, the whole request is rejected immediately.

4

Keycloak authenticates the user

Keycloak checks the submitted username and password against its user store (which may be its own database, or a federated store like LDAP or Active Directory). Password hashing and verification happen entirely inside Keycloak.

5

Keycloak evaluates roles, scopes, and mappers

If the credentials are valid, Keycloak looks up the user’s assigned roles and group memberships, applies any configured protocol mappers, and decides exactly what claims (pieces of information) should go into the resulting tokens.

6

Tokens are generated and signed

Keycloak issues an access token, a refresh token, and (if the “openid” scope was requested) an ID token — each a cryptographically signed JWT that other systems can verify independently.

7

Tokens are returned in the HTTP response

All of this happens within a single request/response cycle. The application receives the tokens directly in the body of the response — there is no redirect step at any point in this flow.

8

App discards the raw password and stores the tokens

A well-built application immediately discards the plaintext password from memory once the request completes, and stores only the returned tokens (ideally in a secure, short-lived manner) for subsequent use.

What makes this flow feel so simple is precisely what makes it risky: everything happens in one round trip, with no opportunity for Keycloak to add extra verification steps mid-flow, such as showing a CAPTCHA, redirecting to a third-party identity provider, or prompting for an additional multi-factor authentication step through its own UI.

sequenceDiagram
    participant U as User
    participant A as Application
    participant K as Keycloak

    U->>A: Enters username & password
    A->>K: POST /token (grant_type=password, client_id, credentials)
    K->>K: Authenticate client
    K->>K: Authenticate user against user store
    K->>K: Resolve roles, scopes, mappers
    K-->>A: access_token, refresh_token, id_token
    A->>A: Discard raw password
    A-->>U: Logged in
        
FIG 2 — The complete single-round-trip lifecycle of a Direct Access Grants request.
!
A Common Misconception

Some developers assume Direct Access Grants is “less secure OAuth” purely because it skips a redirect. The redirect itself isn’t the security feature — what matters is that Keycloak’s own hosted login page can enforce things (like adaptive MFA challenges or external identity broker redirects) that a bare token-endpoint call cannot.

5Understanding the Tokens You Get Back

A successful Direct Access Grants request doesn’t just return “a token” — it typically returns up to three distinct tokens, each with a different job.

Access Token

Proof for APIs

A short-lived token the app attaches to requests to protected APIs. APIs verify its signature and check the claims inside to decide what the caller can do.

Refresh Token

Gets a new access token

A longer-lived token used to obtain a fresh access token once the current one expires, without asking the user to log in again.

ID Token

Proof of identity for the app

Issued when the “openid” scope is requested; it tells the application who the user is (name, email, etc.) rather than what they’re allowed to do.

Simple Analogy

Think of the access token as a day pass that gets you through a specific building’s turnstiles, the refresh token as a renewable membership card you use to print a new day pass once the old one expires, and the ID token as a printed name badge that simply confirms who you are, separate from what you’re allowed to enter.

Why tokens are short-lived on purpose

Access tokens in Keycloak typically expire quickly — often within a few minutes — by design. This is a deliberate security trade-off: if a token is ever leaked or stolen, the window during which it can be misused is small. The refresh token, in turn, allows the application to quietly obtain a new access token in the background, so the user experience stays seamless even though the underlying tokens are rotating constantly.

i
Good Practice

Never store access or refresh tokens in places accessible to untrusted scripts, such as browser localStorage in a public-facing single-page app. Prefer secure, HttpOnly cookies or platform-appropriate secure storage on mobile and backend systems.

What’s inside a JWT, conceptually

Every token Keycloak issues is (by default) a JSON Web Token, or JWT. Without diving into code, the important idea is this: a JWT is made of three parts — a header describing how it’s signed, a payload containing claims (facts like the user’s ID, roles, and expiry time), and a signature that lets any system verify the token hasn’t been tampered with, without needing to call Keycloak every single time. This is what makes tokens so efficient: verification can happen locally, using Keycloak’s published public key.

Why this matters for Direct Access Grants specifically

Because this flow is often used by backend systems and automated clients (rather than interactive browser apps), the ability to verify a token locally — without a network round trip back to Keycloak — is especially valuable for performance in server-to-server scenarios.

6Advantages and Disadvantages

Every design decision is a trade-off. Here’s an honest look at both sides of Direct Access Grants.

Advantages

  • Extremely simple integration — one request, one response, no redirect handling required.
  • Well suited for non-browser environments like command-line tools and automated scripts.
  • Useful for legacy systems being migrated toward centralized identity, where rewriting the entire login UI isn’t feasible right away.
  • Convenient for automated testing pipelines that need to obtain tokens without simulating a browser.
  • No dependency on browser redirect capabilities, cookies, or JavaScript execution.

Disadvantages / Trade-offs

  • The application directly handles the user’s raw password, expanding the security boundary.
  • Bypasses Keycloak’s own login page, so features like adaptive authentication, CAPTCHA, or social login via that page cannot apply.
  • Makes it harder to support login via external identity providers (like a corporate SSO broker) transparently.
  • Deprecated in the OAuth 2.0 security best practices for third-party or public clients.
  • Doesn’t support redirect-based single sign-on across multiple applications as smoothly as Authorization Code flow does.
“Convenience and trust are almost always in tension — Direct Access Grants trades some of the latter for a large amount of the former.”

None of this means the flow is “bad” — it means it is situational. A flow that is a poor fit for a public consumer-facing mobile app might be exactly the right fit for an internal automation script running inside a company’s own trusted infrastructure.

7Security Considerations

This is the most important chapter in the whole tutorial — read it carefully before enabling this flow anywhere.

Why the OAuth 2.0 community moved away from this flow

The IETF’s OAuth 2.0 Security Best Current Practice document explicitly recommends against using the Resource Owner Password Credentials grant, and states that it should be avoided for new applications. The core reasoning is simple: any flow where an application handles raw passwords creates more places where things can go wrong — logging, memory dumps, malicious dependencies, compromised client code, or a poorly secured mobile app can all potentially expose credentials that would never have existed in the application’s process in a redirect-based flow.

!
Not Recommended For

Public clients (like single-page apps or mobile apps you don’t fully control end-to-end), third-party integrations, and any scenario involving untrusted or partially-trusted application code.

When it can still be a reasonable, controlled choice

Despite the general guidance against it, there are narrower situations where Direct Access Grants remains a pragmatic, acceptable choice — precisely because the application is fully trusted and tightly controlled.

Trusted first-party apps

You own both ends

An internal admin tool built and operated entirely by the same organization running Keycloak, with no external distribution.

CLI and automation

No browser available

Command-line utilities or CI/CD pipeline steps that need a token but have no way to open an interactive browser session.

Legacy migration

Transitional bridge

An older system being incrementally migrated to Keycloak, where the existing login form can’t be replaced overnight.

Automated testing

Non-production only

Test suites that need to authenticate quickly and repeatedly without simulating full browser redirect behavior.

Concrete hardening steps

1

Restrict which clients can use it

Only enable “Direct Access Grants Enabled” for the specific clients that genuinely need it — leave it off for everything else, especially public/browser-based clients.

2

Always use TLS

Because credentials travel in the request body, the connection between the app and Keycloak must always be encrypted end-to-end — never allow this over plain HTTP.

3

Keep client secrets confidential

Only use this flow with confidential clients that can securely store a client secret — never with public clients that ship secrets inside distributable app binaries.

4

Enforce short token lifetimes

Keep access token lifespans short and monitor refresh token usage patterns to reduce the impact of any potential leak.

5

Apply brute-force protection

Enable Keycloak’s built-in brute-force detection so repeated failed password attempts through this endpoint get throttled or locked out.

6

Never log raw credentials

Audit your application and any proxies or gateways in front of Keycloak to make sure request bodies containing passwords are never written to logs.

8Monitoring, Logging, and Metrics

Enabling a flow is only half the job — knowing what “healthy” and “suspicious” usage looks like is the other half.

What to watch in Keycloak’s own logs and events

Keycloak can be configured to emit login events, and these are especially valuable for a password-based flow because there’s no browser session to inspect afterward — the event log becomes your primary window into what happened.

Login
success / error events
Token
issuance & refresh events
Client
per-application breakdown
Failed login rate

Detect brute-force attempts

A sudden spike in failed password attempts against this endpoint from a single client or IP is a strong signal of an automated attack.

Token issuance volume

Baseline vs anomaly

Track how many tokens each client issues per hour; a sudden unexplained jump can indicate credential stuffing or a leaked client secret.

Refresh token reuse

Possible token theft

If refresh token rotation is enabled and Keycloak detects reuse of an already-rotated refresh token, that’s a strong sign of token theft in progress.

Client usage drift

Unexpected new callers

If a client that was only ever meant for internal automation suddenly shows traffic from unfamiliar IP ranges, investigate immediately.

i
Practical Tip

Forward Keycloak’s event stream into your existing observability stack (whatever log aggregation or SIEM tool your organization already uses) rather than only relying on the built-in admin console, so alerts can be automated rather than manually checked.

Metrics worth putting on a dashboard

Beyond raw logs, exposing Keycloak’s metrics endpoint to your monitoring system lets you track trends over time rather than just individual events: authentication success/failure ratios per client, average token issuance latency, and the proportion of traffic coming through this particular grant type relative to others. If Direct Access Grants traffic starts creeping up unexpectedly as a share of total logins, that’s worth a conversation about whether it’s being used where it shouldn’t be.

9Design Patterns and Anti-Patterns

Some usage patterns are sound engineering; others quietly introduce risk. Here’s how to tell them apart.

ANTI-PATTERN-01 Avoid
Problem

Using Direct Access Grants as the login mechanism for a public single-page web application or a mobile app distributed to end users.

Why It’s Harmful

Public clients can’t reliably keep a client secret confidential, and the app’s own JavaScript or mobile code directly touches the user’s raw password, widening the attack surface significantly compared to a redirect-based flow.

Correct Approach

Use the Authorization Code flow with PKCE instead, so the password is only ever typed into Keycloak’s own hosted login page, never into application code you distribute publicly.

ANTI-PATTERN-02 Avoid
Problem

Leaving “Direct Access Grants Enabled” turned on for every client by default, “just in case,” without a specific need.

Why It’s Harmful

Each enabled client is an additional door through which password-based requests can be attempted, expanding the attack surface with no corresponding benefit.

Correct Approach

Treat the toggle as opt-in per client, enabled only after a deliberate decision that this specific integration genuinely needs it.

Sound Pattern: Scoped automation client

Create a dedicated, narrowly-scoped confidential client used only by your internal automation or CI pipeline, with Direct Access Grants enabled just for that one client, and roles restricted to exactly what the automation needs — nothing more.

Sound Pattern: Transitional legacy bridge

When migrating a legacy system that already owns its login UI, use Direct Access Grants as a temporary bridge to Keycloak-issued tokens, paired with a documented plan to migrate to a redirect-based flow once the legacy front end can be replaced.

10Best Practices and Common Mistakes

A condensed, practical checklist for teams actually implementing this flow.

Advantages

  • Enable it only on clients that truly need it, and document why.
  • Pair it with short token lifetimes and refresh token rotation.
  • Use confidential clients with securely stored secrets, never embedded in shipped code.
  • Combine it with brute-force detection and rate limiting at the network layer.
  • Regularly review which clients have the toggle enabled as part of a security audit.

Common Mistakes

  • Enabling it on public, browser-based, or widely distributed clients.
  • Storing the user’s password temporarily in application logs during debugging.
  • Forgetting to disable it once a legacy migration is complete.
  • Skipping TLS in internal/test environments, assuming “it’s just internal.”
  • Not monitoring failed-login rates specifically for this grant type.
i
Rule of Thumb

If you can’t confidently answer “who controls every line of code that touches this password before it reaches Keycloak,” you should not be using Direct Access Grants for that integration.

11Real-World and Industry Examples

Seeing where organizations actually apply this flow helps ground the theory in practice.

Internal DevOps tooling

CI/CD pipeline authentication

Engineering teams commonly use Direct Access Grants inside continuous integration pipelines to obtain a token for deploying artifacts or calling internal APIs, since there’s no interactive browser available in that context.

Legacy system bridges

Gradual identity consolidation

Enterprises migrating dozens of older internal applications onto a single Keycloak realm often use this flow temporarily, so the legacy apps’ existing login screens keep working while identity is centralized behind the scenes.

Command-line developer tools

Local CLI authentication

Internal command-line tools used by engineers to interact with company infrastructure often use this flow to authenticate quickly from a terminal, in environments the organization fully controls.

Automated test suites

Fast, repeatable test logins

QA and testing teams frequently rely on this flow to obtain tokens for automated test runs, avoiding the overhead of simulating a full browser redirect for every test execution.

Across these examples, notice the common thread: in every legitimate real-world use, the organization fully controls both the client application and the environment it runs in. None of them involve handing the flow to a third-party developer or shipping it inside a public app store binary — and that consistency is exactly what the security guidance in Chapter 7 recommends.

12Direct Access Grants vs. Other Keycloak Flows

A side-by-side view makes the trade-offs concrete.

FlowWho sees the passwordNeeds a browserBest for
Authorization Code (+ PKCE)Only Keycloak’s login pageYesWeb apps, mobile apps, public clients
Direct Access GrantsThe application itselfNoTrusted internal apps, CLIs, automation
Client CredentialsNo user password involvedNoService-to-service, no human user
Device AuthorizationOnly Keycloak’s login page, on a separate deviceYes, on a secondary deviceSmart TVs, IoT, screenless devices

Reading this table, a clear pattern emerges: Direct Access Grants is the only flow among the common ones where the requesting application itself directly handles the raw password. Every other flow either removes the password entirely from the picture (Client Credentials) or keeps it confined strictly to Keycloak’s own trusted login surface (Authorization Code, Device Authorization).

13Frequently Asked Questions

Q1Is Direct Access Grants the same as the Resource Owner Password Credentials grant?

Yes. “Direct Access Grants” is simply Keycloak’s user-friendly label for the OAuth 2.0 Resource Owner Password Credentials (ROPC) grant type — they refer to the exact same mechanism.

Q2Is this flow deprecated?

Keycloak still supports and implements it, but the broader OAuth 2.0 security best practices guidance recommends against using it for new applications, especially public or third-party clients, in favor of the Authorization Code flow with PKCE.

Q3Can this flow support multi-factor authentication?

Not in the same rich way the Authorization Code flow can, because it bypasses Keycloak’s own hosted login page where interactive MFA challenges are typically presented. Some limited, non-interactive additional factors can be layered on, but the flow’s single-round-trip nature makes rich adaptive MFA difficult.

Q4Do I need a client secret to use this flow?

If the client is configured as confidential (the recommended setup for this flow), yes, a client secret must be sent along with the request. Public clients technically can use this flow too, but doing so is strongly discouraged since they cannot keep a secret confidential.

Q5Does Direct Access Grants support single sign-on across multiple apps?

Not naturally. Because there’s no browser session or redirect involved, Keycloak’s usual browser-based SSO cookie mechanism doesn’t come into play the same way it does with the Authorization Code flow, where a single Keycloak session can silently authenticate the user into multiple applications.

Q6Should I use this for my public-facing mobile app?

Generally, no. Mobile apps distributed to end users are considered public clients, and the recommended approach is Authorization Code flow with PKCE, using an embedded browser or system browser to show Keycloak’s own login page.

Q7Can refresh tokens from this flow be used the same way as from other flows?

Yes — once issued, a refresh token behaves the same regardless of which flow originally produced it, and can be used to obtain new access tokens until it expires or is revoked.

14Summary and Key Takeaways

Direct Access Grants is Keycloak’s implementation of the OAuth 2.0 Resource Owner Password Credentials grant: a flow where an application collects a user’s username and password itself and exchanges them directly for tokens in a single request to Keycloak’s token endpoint, with no browser redirect involved. It’s simple, fast, and well-suited to trusted, tightly-controlled environments like internal automation, command-line tools, and legacy migration bridges — but it also means the requesting application becomes part of the security boundary around the user’s raw password, which is why broader OAuth guidance steers public and third-party applications toward the redirect-based Authorization Code flow instead. Used deliberately, on the right clients, with strong hardening (TLS, short-lived tokens, brute-force protection, and careful monitoring), it remains a legitimate and useful tool in Keycloak’s toolbox rather than something to avoid outright.

Key Takeaways

  • It’s the ROPC grant — Direct Access Grants is Keycloak’s name for OAuth 2.0’s Resource Owner Password Credentials flow.
  • The app handles the password directly — unlike redirect-based flows, the requesting application’s own form collects the raw credentials.
  • One round trip, three possible tokens — a single request can return an access token, a refresh token, and an ID token.
  • Best for trusted, controlled environments — internal automation, CLI tools, and legacy bridges are the strongest fits.
  • Avoid for public or third-party clients — browser-based apps and distributed mobile apps should use Authorization Code with PKCE instead.
  • Security requires deliberate hardening — TLS everywhere, confidential clients only, short token lifetimes, and active brute-force monitoring.
  • Enable it per-client, never by default — treat the “Direct Access Grants Enabled” toggle as an explicit, reviewed decision for each client.