You're absolutely right to question this recommendation in the context of a first-party client (e.g., your own website talking to your own backend). The RFC's warning is primarily aimed at third-party clients (e.g., a random app asking for your Gmail password), where the Password Grant flow is indeed a security anti-pattern.
Why the RFC Discourages Password Grant (for Third-Party Clients)
- Credential Exposure: The client app gets the user's raw username/password, which is bad if the client is untrusted (e.g., a third-party app).
- Phishing Risk: Users get trained to enter credentials into non-official UIs.
- Attack Surface: Credentials are now stored/handled in more places (client + auth server).
Why It’s Fine (or Even Good) for First-Party Clients
If you control both the client and the backend, the arguments mostly don’t apply:
- The client is part of your trusted system (like your website or official mobile app).
- You’re not training users to enter credentials into untrusted UIs.
- You’re not exposing credentials to third parties.
In this case, the Password Grant flow is essentially just a standardized way to do what you’d otherwise implement manually: sending a username/password to your backend and getting a token back. Rolling your own ad-hoc auth protocol is worse because:
- You lose interoperability (e.g., OAuth2 libraries, tooling).
- You might introduce security flaws (e.g., not using HTTPS, mishandling tokens).
Practical Advice
- If your client is first-party, the Password Grant is fine. Many large companies (e.g., legacy systems, internal apps) use it this way.
- If your client is third-party, use Authorization Code Flow + PKCE (for native/public clients) or Client Credentials (for machine-to-machine).
- Consider alternatives even for first-party:
- Authorization Code Flow: More work, but better long-term (e.g., if you later need third-party clients).
- Session Cookies: For web apps, traditional cookie-based auth is often simpler than OAuth2.
RFC 9700’s Context
The RFC is focused on modern best practices for OAuth2, where the Password Grant is a legacy holdover. It’s not wrong, but it’s overly strict for first-party cases. The OAuth2 spec itself [RFC 6749] still allows the Password Grant, and it’s not deprecated—just discouraged for most use cases.
Bottom Line
For your own frontend+backend, using Password Grant is not stupid. It’s a pragmatic choice, especially if:
- You don’t need to support third-party clients.
- You want to avoid the complexity of the Authorization Code Flow.
- You’re using HTTPS and handling credentials securely.
Just document that you’re intentionally using it for a first-party client, and don’t expose it to third parties. If you later need to support third-party clients, you can add Authorization Code Flow alongside it.