The password grant
The password grant let an application trade a person's username and password for tokens at the token endpointThe authorization server address where clients exchange an authorization code, refresh token, or other grant for tokens, in a direct request rather than through a browser redirect.. OAuth 2.0A framework that lets a person give an application limited access to their resources at another service, using tokens instead of sharing their password. OAuth is about access; OpenID Connect adds sign-in. included it as a step away from applications that stored passwords, and current guidance forbids it because it keeps the problem OAuth set out to remove.
A token for a password
The first version of photos-cli, the photo service's own command-line tool, began every sessionThe ongoing connection between later requests and an earlier sign-in, so you are not asked for your password on every click. It is often tracked with a cookie holding an unpredictable session identifier. the same way. It asked Ava for her photo account's username and password, right there in the terminal, traded them for tokens, and, to its credit, never saved the password.
That trade was the resource ownerIn OAuth, the person who can authorize access to protected resources, such as you deciding whether a printing app may read your photos. password credentials grant, usually called the password grant. It was part of OAuth 2.0 from the start, and current security guidance says it must not be used.
All values in these examples are fictional, including the password. The tool sent what Ava typed straight to the tokenA piece of data issued by a trusted service that a client presents as a credential, for example to call an API or to report a sign-in. Some tokens carry readable claims; others are random strings that only the issuer can interpret. endpoint:
POST /token HTTP/1.1
Host: auth.photos.example
Content-Type: application/x-www-form-urlencoded
grant_type=password
&username=ava%40photos.example
&password=demo-password-not-real
&scope=photos.read
&client_id=photos-cliThere is no browser, no redirect, no code, and no approval screen. The authorization serverIn OAuth, the service that handles a person's sign-in and approval and decides which tokens to issue to a client. It may belong to the same company as the API, but its job is separate. checked the password with its normal sign-in logic and, if it was right, returned an ordinary token response, often with a refresh tokenA longer-lived credential that a client sends to the authorization server, never to an API, to get new access tokens without asking the person again. so the tool would not need the password again. A confidential clientAn OAuth client, typically running on a backend, that can keep a credential such as a client secret or private key protected, and so can authenticate itself to the authorization server. would also have authenticated itself in the same request. photos-cli, installed on many people's computers, was a public clientAn OAuth client, such as code running in a browser or an app on a phone, that cannot keep a credential secret because the people using it can inspect it. It relies on protections such as PKCE instead of a client secret. and sent only its client ID.
Why it was included
When OAuth 2.0 was written, plenty of applications already held users' passwords. Desktop mail programs, phone apps, and scripts signed in to APIs with HTTPThe Hypertext Transfer Protocol, the rules browsers, apps, and servers use to send requests and responses on the web. Basic authenticationChecking evidence that someone, or some application, controls an account, such as a password or a passkey. It establishes which account is being used, not what that account may do., the encoded username and password from Public and confidential clients, or its Digest variant, which sends a hashTurning data into a short, fixed-size value called a hash, in a way that cannot be reversed and where changing one character changes the result completely. Services store password hashes instead of passwords, and signatures are made over a hash. computed from the password instead. Either way they sent proof of the password with every request and stored the password so they could. RFC 6749 offered the password grant as a step away from that: exchange the password once for a token, then forget it.
The specification hedged it heavily. It described the grant as suitable only where the person had a high degree of trust in the client, such as the device's operating system or a highly privileged application, and only when other grants were not available. In practice, many services also used it for their own applications, where the tool and the authorization server belonged to the same organization. If photos-cli is the photo service's own tool, why send Ava through a browser to type the same password into the same company's page?
What it costs
The answer is that the password grant keeps the very problem OAuth was created to remove. The client sees Ava's password. Even a well-behaved client can leak it through a crash report, a debug log, or a compromised computer, and a less honest one can simply keep it. The authorization server cannot tell whether the request came from Ava or from a script trying stolen passwords, which is why RFC 6749 itself required the endpoint to be protected against brute-force attempts.
It also freezes sign-in at a username and a password. The client knows how to collect two fields and nothing else. If the photo service adds a second factor, offers passkeys, or lets business accounts sign in through their company's identity provider, the password grant cannot take part, because none of those steps fits into a form that the client posts. Passkeys and similar credentials are usually bound to the authorization server's own web origin, so a form inside another application often cannot use them at all. Services that kept the grant often found it was the one sign-in path their stronger protections did not reach.
Ava loses her part in the decision, too. There is no approval screen, so nothing shows her which application is asking or what it will be able to do; the client chooses the scope. And every legitimate application that asks for a photo service password teaches people that typing it into other applications is normal, which is exactly the habit a phishing page relies on.
photos-cli posts her password
- Who sees the password
- photos-cli
- Second factor or passkey
- No place for it
- Approval screen
- None
- Ava or a script?
- Server cannot tell
Must not be used
photos-cli opens the browser
- Who sees the password
- The photo service's own page
- Second factor or passkey
- Asked on that page
- Approval screen
- Shows which application asks
- Ava or a script?
- Ava signs in herself
The tool never sees the password
Current guidance
The OAuth 2.0 Security Best Current Practice, RFC 9700, is direct: the password grant MUST NOT be used. It names the exposure of the person's credentials to the client, the habit it teaches, and its incompatibility with multi-step and cryptographic authentication. OAuth 2.1, the working group's consolidation of OAuth 2.0, leaves the grant out as well.
The replacements depend on the client. An installed application, whether it belongs to the photo service or to someone else, opens the system browser for the authorization code flow with PKCE, as Native applications described. A command-line tool like photos-cli can do the same with a loopback redirect, or use the device authorization grant when it runs where no browser is available, as Command-line tools compared. Either way, the password is typed only on the photo service's own page, which can ask for whatever else the account requires.
The most common reason the grant survives today is automated testing, because a script can sign in a test user without driving a browser. Tests have better options, such as a test authorization server that issues tokens for test accounts, or client credentials when the test concerns a service rather than a person. A grant left enabled for tests tends to stay enabled for everything else as well.
Check your understanding
Try these questions before moving on. If an answer isn't right, use the feedback and try again.
Try it in the Lab
- Meet unsupported_grant_type, then sign in the browser way with a second stepSee the token endpoint refuse a password grant, replace it with the loopback code flow a command-line tool should use, and add a second sign-in step that only the browser flow can carry.