Skip to content
Back to Blog
Article

Salesforce OAuth Errors: A Troubleshooting Reference

Sep 2, 2026
SCSunny Chauhan
Salesforce OAuth Errors: A Troubleshooting Reference

Salesforce OAuth failures split into two groups that look similar and are fixed in completely different places. Errors returned by the authorization or token endpoint, such as invalid_grant and redirect_uri_mismatch, are configuration problems in the OAuth app. INVALID_SESSION_ID, returned by an API call, is a token lifecycle problem in your client.

Getting that split right saves the afternoon. Nobody has ever fixed INVALID_SESSION_ID by editing callback URLs, and plenty of people have tried.

Start here: which kind of error is it?

Where the error came backWhat it isWhere the fix lives
The /services/oauth2/authorize or /services/oauth2/token endpointAn OAuth errorYour app configuration or the request you sent
Any API call, after you already had a tokenA session or permission errorYour token handling, or the user's access

The OAuth errors Salesforce documents

ErrorWhat Salesforce saysWhat it usually means in practice
invalid_grantMany causes: invalid authorization code, invalid credentials, invalid user, invalid assertion, invalid audience, IP restrictions, code_verifier issues, missing user approval, authentication failure, expired tokensThe catch-all. Work through the list below
redirect_uri_mismatchRedirect URI mismatch with the app definitionA trailing slash, http instead of https, or the wrong environment's callback
redirect_uri_missingRedirect URI not providedThe parameter was dropped, often by a proxy
invalid_client_idClient identifier is invalidWrong client ID, or a key copied with whitespace
invalid_clientClient secret is invalidWrong or rotated secret
invalid_requestHTTPS is required, HTTP GET or POST is required, invalid code_challenge, unsupported parameters, invalid device codeA malformed request rather than bad credentials
invalid_scopeThe requested scope is invalid, unknown or malformedAsking for a scope the app was not granted
invalid_app_accessUser isn't approved by an admin to access this appApp policy is set to admin-approved users only
inactive_userUser is set to inactive by the org's adminSomeone deactivated the integration's user
inactive_orgOrg is locked, closed or suspendedNothing you can fix in code
access_deniedUser denied access to the client appThe user clicked Deny
rate_limit_exceededNumber of login attempts has been exceededRetry storm, usually your own
server_errorThe number of authorization requests from the client app exceeds the hourly limitYou are re-authorizing in a loop
CSRFA possible cross-site request forgery was detectedThe login request did not come from the expected domain
No_OAuth_StateThe OAuth state was tampered with or is missingState lost across a redirect
immediate_unsuccessfulimmediate is true and the user is not logged in or has not previously approved accessExpected, when using immediate mode
authorization_pendingDevice flow, the user has not approved yetKeep polling
slow_downDevice flow, you are polling more often than the recommended intervalBack off
unsupported_response_typeRequested response type isn't supportedWrong response_type for the flow
NO_ACCESSUnable to find a userNo matching user, for example no username
ERROR_CREATING_USERUsername not unique, a contact exists for the email, the user lacks a licence, or a storage limit was exceededJust-in-time provisioning failed
REGISTRATION_HANDLER_ERRORA problem with your registration handler Apex codeYour handler threw
No_Openid_ResponseUser Info Endpoint URL is invalidAuth provider misconfiguration
invalid_assertion_typeSpecified assertion type isn't supportedWrong assertion mechanism

Working through invalid_grant

invalid_grant covers the most ground, so it needs a checklist rather than a fix. Work down it in this order, because the top entries are the most common and the cheapest to test.

  1. Is the refresh token expired or revoked? Check the app's Refresh Token Policy under Policies, then OAuth Policies, then App Authorization. If it is set to expire and your integration is long-lived, this is the answer. "Refresh token is valid until revoked" is the setting long-running integrations want.
  2. Was the authorization code already used? Codes are single use and short lived. A retry that replays the same code fails here.
  3. Did an admin revoke the app? Revoking access in Setup invalidates every issued token, and the failure looks identical to expiry.
  4. Is there an IP restriction? IP relaxation settings on the app can reject a token request from an address that was fine last week, which is what happens when a cloud provider rotates egress IPs.
  5. Is PKCE mismatched? A code_verifier that does not match the code_challenge you sent produces invalid_grant, not a PKCE-specific error.
  6. Does the user still exist and still have access? An inactive user or a removed permission set assignment lands here too.

If the app issues JWT-based access tokens, the hybrid app refresh token flow returns invalid_grant on a token request. Refresh token rotation in that flow is supported only with opaque access tokens, so the fix is the token format rather than anything about the request.

Fixing redirect_uri_mismatch

The single most common OAuth failure, and the error text never tells you which part differs. Salesforce compares the redirect URI on the request against the stored value character for character.

The four differences that cause it, in rough order of frequency:

  • A trailing slash on one side and not the other
  • http where the app has https
  • The callback for a different environment, staging against production
  • A URL retyped by hand rather than copied

Copy and paste, always. Add every environment's callback to the same app rather than keeping several apps in step, since redirect URLs stay editable after creation.

INVALID_SESSION_ID is a different problem

This one comes back from an API call, not from the token endpoint, and it means the access token you presented is no longer valid.

CauseFix
The access token expiredRefresh it. Expected behaviour, not a fault
Session timeout on the org reachedRefresh, and check the session settings if it happens sooner than expected
The app or token was revokedRe-authorize
You called the wrong instance URLUse the instance_url returned with the token, not a hardcoded host

That last row is worth checking first when the error appears on a connection that has never worked. Salesforce returns instance_url alongside the access token precisely so you do not have to guess, and a hardcoded login.salesforce.com for API calls produces exactly this error.

The right pattern is to treat INVALID_SESSION_ID as a normal signal rather than an exception: catch it, refresh once, retry the call once, and only then surface a failure. Integrations that instead refresh proactively on a timer end up doing both, and are the ones that trip rate_limit_exceeded.

One unexpected cause of invalid_client_id

Nango's Salesforce troubleshooting documents a cause that is worth knowing before it costs you a day: this error can be produced by the developer user's password containing special characters. If the client ID is definitely correct and the request still fails, that is the thing to check.

Preventing most of this

Three configuration choices remove the majority of recurring OAuth failures.

Set the Refresh Token Policy deliberately. Under Policies, then OAuth Policies, then App Authorization. Leave it on a short expiry and your integration will keep dying on a schedule nobody connects to a setting.

Add every environment's callback to one app. Cheaper than keeping several apps in step, and it removes the whole class of staging-versus-production mismatches.

Use an external client app for anything new. Connected app creation through the UI was turned off by default on new orgs in Winter '26, and re-enabling it has required Salesforce Support since Spring '26. Existing connected apps keep working, and App Manager offers a migration path for eligible ones.

If you need one provisioned rather than built by hand, Appnigma's external client app provisioner issues the client ID, secret and a managed package install link.

Frequently Asked Questions

What causes invalid_grant in Salesforce?

Salesforce documents many causes under one code: an invalid or already-used authorization code, invalid credentials, an invalid user or assertion, IP restrictions, a mismatched code_verifier, missing user approval, and expired tokens. The most common in production is an expired or revoked refresh token, which is controlled by the app's Refresh Token Policy.

How do I fix redirect_uri_mismatch in Salesforce?

Make the callback URL on the Salesforce app match the one your client sends, character for character. The usual differences are a trailing slash, http instead of https, or a callback copied from a different environment. Copy and paste the value rather than retyping it, and add every environment's callback to the same app.

What does INVALID_SESSION_ID mean?

The access token presented on an API call is no longer valid, usually because it expired, the session timed out, or access was revoked. It can also mean you called the wrong host, so always use the instance_url returned with the token rather than a hardcoded login domain. Handle it by refreshing once and retrying once.

Why does my Salesforce refresh token keep expiring?

Because the app's Refresh Token Policy is set to expire. Change it under Policies, then OAuth Policies, then App Authorization. For long-lived integrations, "Refresh token is valid until revoked" is the setting you want.

Is INVALID_SESSION_ID an OAuth error?

No. OAuth errors come back from the authorization or token endpoint and point at app configuration. INVALID_SESSION_ID comes back from an API call and points at token lifecycle handling in your client. They are fixed in different places.

What causes rate_limit_exceeded on Salesforce OAuth?

The number of login attempts has been exceeded. In practice it is almost always a retry loop in your own integration, often one that refreshes proactively on a timer as well as reactively on failure. Refresh on failure only.

Can I still create a connected app in Salesforce?

Existing connected apps keep working, but creation through the UI was turned off by default on new orgs in Winter '26, and re-enabling it has needed approval from Salesforce Support since Spring '26. New integrations should start with an external client app.

Sources

  1. Salesforce Help, OAuth 2.0 Authorization Errors: the documented error codes and descriptions quoted above. 2/ Salesforce Help, OAuth 2.0 Hybrid App Refresh Token Flow: JWT-based access tokens and refresh token rotation. 3/ Salesforce Help, Invalid Session ID knowledge articles and External Client Apps. 4/ Nango Docs, Salesforce troubleshooting: developer password special characters as a cause of invalid client ID. 5/ Appnigma, external client app product flow verified 2 September 2026.

All Blogs