Skip to content

OAuth2 Resource Owner Password Credentials — Direct Credential Exchange

DodaTech Updated 2026-06-28 3 min read

In this tutorial, you will learn about OAuth2 Resource Owner Password Credentials. We cover key concepts, practical examples, and best practices to help you master this topic.

The Resource Owner Password Credentials (ROPC) grant allows a client to exchange a user's username and password directly for an access token, bypassing the redirect-based authorization.

What You'll Learn

How ROPC works, its severe security limitations, why it is being deprecated, and suitable alternatives.

Why It Matters

ROPC is the most dangerous OAuth2 grant. It requires the client to handle passwords — the exact problem OAuth2 was designed to avoid. Understanding why it is dangerous helps you avoid and migrate away from it.

Real-World Use

ROPC was sometimes used for first-party mobile apps (the company owns both the app and the API). Most providers (Google, Microsoft, GitHub) have deprecated ROPC for new applications.

flowchart LR
    A["User"] -->|"Username + Password"| B["Client App"]
    B -->|"POST /token\ngrant_type=password"| C["Auth Server"]
    C -->|"Access + Refresh Tokens"| B
    B -->|"API call + Token"| D["Resource Server"]
    style A fill:#dbeafe,stroke:#2563eb
    style B fill:#fecaca,stroke:#dc2626
    style C fill:#fef3c7,stroke:#d97706
    style D fill:#dcfce7,stroke:#16a34a

Why ROPC Is Dangerous

Risk Description
Password exposure The client app handles plain-text passwords
No granular consent User cannot approve specific scopes
No MFA support Password grant cannot handle MFA challenges
Credential storage Client may store passwords for convenience
Deprecated OAuth2 BCP recommends against it

Common Mistakes

1. Using ROPC for Third-Party Apps

Third-party apps should never see user passwords. Use Authorization Code.

2. Not Handling MFA

ROPC fails when MFA is enabled. The error response does not indicate whether the password was correct.

3. Storing Passwords in Client

The client should discard the password immediately after token exchange.

4. Confusing ROPC with Client Credentials

ROPC uses user credentials. Client Credentials uses app credentials. Different purposes.

5. Believing ROPC Is Secure

Even with HTTPS, the password is exposed to the client application.

Practice Questions

  1. What grant collects usernames and passwords directly?
  2. Why is ROPC considered less secure than Authorization Code?
  3. What happens when MFA is enabled and a user uses ROPC?
  4. Is ROPC appropriate for third-party apps?
  5. What is the recommended alternative?

Answers:

  1. Resource Owner Password Credentials (grant_type=password).
  2. The client handles plain-text passwords. Authorization Code keeps passwords between user and auth server.
  3. The password grant fails because it cannot handle MFA challenges. Returns invalid_grant error.
  4. No. Third-party apps should never see user passwords.
  5. Authorization Code with PKCE provides the same UX without password exposure.

Challenge: Convert a password-grant flow to Authorization Code with PKCE. Explain the security improvements and UX differences.

FAQ

Is ROPC completely deprecated?

The OAuth2 Security BCP recommends against it. Major providers (Google, Microsoft) no longer support new ROPC applications.

Can ROPC be used for testing?

Yes, for local development. Never use in production.

Does ROPC support refresh tokens?

Yes. The auth server may issue a refresh token along with the access token.

What scopes can be requested with ROPC?

The client requests scopes, but the user cannot selectively approve them — another security limitation.

How do I migrate from ROPC to Authorization Code?

Change your app to redirect users to the auth server's login page. User passwords never touch your app.

Mini Project

Write a script demonstrating why ROPC fails with MFA, then implement the same scenario using Authorization Code.

What's Next

Now learn about PKCE Extensions — the security extension for public OAuth2 clients.

Built by the developers of DodaTech

Doda Browser, DodaZIP & Durga Antivirus Pro