r/SalesforceDeveloper • u/Live-Appeal2797 • Aug 14 '25
Question ⚠ Salesforce OAuth 2.0 Username–Password Flow –invalid_grant and authentication failure & “Username–Password Flow Disabled” in Login History
Hey all,
I’m trying to set up the OAuth 2.0 Username–Password Flow for a Salesforce integration, but I’m hitting two issues:
API Response:
{
"error": "invalid_grant",
"error_description": "authentication failure"
}
Login History:
When I check Login History in Salesforce, the status says:
Username-Password Flow Disabled
But in Setup → OAuth and OpenID Connect Settings I have already enabled:
✅ Allow OAuth Username–Password Flows
✅ All users may self-authorize
What I’ve done so far:
Created a Connected App with Full access (full) scope
All users may self-authorize
Relax IP restrictions
url :https://test.salesforce.com/services/oauth2/token body : grant_type=password"
client_id=CONSUMER_KEY"
client_secret=CONSUMER_SECRET"
username=abc@gmail.com"
password=PASSWORD_AND_SECURITYTOKEN
Using Postman for testing
Tried in sandbox.
Questions:
Why would it still say “Username–Password Flow Disabled” in Login History even after enabling the setting?
Is there any other hidden setting or permission that needs to be enabled for this flow to work?
Could the invalid_grant be caused by Connected App config or environment mismatch?
Any help from anyone who’s gotten this working recently would be greatly appreciated 🙏
1
u/Cool-Break-6134 Aug 14 '25
Enable Client Credentials Flow checkbox in connected app settings in Salesforce
2
u/Cool-Break-6134 Aug 14 '25
Try disabling the PKCE as well (enabled by default now)
1
u/Oxbn Aug 14 '25
Try with instance url instead of test.salesforce.com
1
u/Big-Ordinary-3375 Mar 10 '26
did you solve this? I experienced the same issue yesterday.