Skip to contentIntroducing the Integration Factory
Back to Blog
Article

How to Fix Salesforce OAuth Errors, From invalid_grant to OAUTH_APPROVAL_ERROR_GENERIC

Sunny Chauhan

Most Salesforce OAuth errors trace back to one of three places. The app's setup in the org (whether it is installed, who may use it, its refresh token and IP policies), the request your client sends (host, callback URL, credentials), or the token lifecycle in your client. OAUTH_APPROVAL_ERROR_GENERIC means the connected app isn't installed in the org and the user lacks the "Approve Uninstalled Connected Apps" permission, a restriction Salesforce began enforcing in September 2025. invalid_grant covers many causes, and its error_description tells you which one, including the new 30-day idle limit on refresh tokens. INVALID_SESSION_ID comes back from an API call, not from the token endpoint, and means the access token is no longer valid.

If you run a SaaS product that connects to your customers' Salesforce orgs, every one of these errors is a customer-facing integration failure. It arrives from an org you don't control, it blocks that customer's onboarding or sync, and the fix usually needs their admin. For a SaaS team the real question is how to keep every customer's connection authorized, with the app installed in each org, inside each admin's policies and refreshed before the 30-day limit. The section on customer orgs covers that, and where Appnigma's integration infrastructure and done for you engineers take it on.

Updated October 2026. Added OAUTH_APPROVAL_ERROR_GENERIC, the 30-day refresh token idle limit, the client credentials and JWT bearer causes of invalid_grant, and corrected the connected app policy paths against current Salesforce documentation.

How to tell which Salesforce OAuth error you have

To identify a Salesforce OAuth error, start with where it came back and what the error_description says. Salesforce puts the error and its description in the callback URL for the authorize step, and in the JSON body for the token request, as listed on its OAuth 2.0 Authorization Errors page.

Where the error came backWhat it isWhere the fix lives
The /services/oauth2/authorize step, shown in the callback URL or an error screenAn authorization errorApp installation and policies in the org, or the callback URL
The /services/oauth2/token endpoint, as JSONA token errorYour credentials, host, grant or the org's token policies
Any API call after you already had a tokenA session errorYour token handling, or the user's access

A token error looks like this. The error_description is the part to read.

{"error": "invalid_grant", "error_description": "expired access/refresh token"}
Where Salesforce returns OAuth errors: in the callback URL for the authorize step, in the JSON body for the token endpoint, and as INVALID_SESSION_ID on API calls.

OAUTH_APPROVAL_ERROR_GENERIC means the app isn't installed in the org

OAUTH_APPROVAL_ERROR_GENERIC appears when a user tries to authorize a connected app that isn't installed in their Salesforce org and the user doesn't have the "Approve Uninstalled Connected Apps" permission. Salesforce's connected app usage restrictions notice says that starting in early September 2025, Salesforce restricts the use of uninstalled connected apps, and that users without that permission see this error.

The user sees "We can't authorize you because of an OAuth error. For more information, contact your Salesforce administrator." The callback URL carries error=invalid_client with error_description=app must be installed into org, which is why the same failure can look like a client secret problem. If the org has API Access Control turned on, the user is redirected with error=OAUTH_APP_BLOCKED instead.

Users who authorized the app before the change keep working, unless the app uses the device flow. Any new user is blocked until an admin acts.

How an admin fixes it:

  1. In Setup, open Connected Apps OAuth Usage, find the app and install it. The same page is where untrusted apps can be blocked.
  2. Or grant "Approve Uninstalled Connected Apps" through a permission set. Salesforce assigns it automatically only to the System Administrator standard profile, so custom profiles, including clones of System Administrator, don't have it.
  3. In a sandbox where the permission can't be granted, Salesforce's notice points to running "Match Production Licenses to Sandbox without a Refresh".
Two ways to fix OAUTH_APPROVAL_ERROR_GENERIC: install the app from Connected Apps OAuth Usage, or grant the Approve Uninstalled Connected Apps permission.

After the app is installed, its Permitted Users policy decides who can use it, and the guides that rank for this error disagree on which setting to pick. This table follows Salesforce's connected app OAuth policies page.

Decision diagram for the Salesforce Permitted Users policy: self-authorize, admin approved with profiles, or admin approved for a JWT integration user.
What you wantSettingWhat to watch
Anyone in the org can connect after approving onceAll users may self-authorize (the default)Each user sees the approval screen the first time
Only chosen users can connect, with no approval screenAdmin approved users are pre-authorized, plus profiles or permission setsUsers not added lose access when you switch
A server-to-server JWT integrationAdmin approved users are pre-authorized for the integration userJWT bearer needs prior approval, or it returns "user hasn't approved this consumer"

Users with the "Use Any API Client" permission can reach any connected app, even one set to admin approved users only, per the same policies page.

invalid_grant error descriptions and what each one means

invalid_grant is the token endpoint's catch-all, so the error_description matters more than the code. Salesforce's authorization errors page lists an invalid authorization code, invalid user credentials, an invalid user, an invalid assertion or audience, "IP restricted or invalid login hours", "User hasn't approved the connected app", "Authentication failure", and an expired refresh or access token.

invalid_grant with "expired access/refresh token"

A refresh token that is no longer valid returns expired access/refresh token. Since Winter '27, Salesforce limits the idle time-to-live of refresh tokens to 30 days, so a refresh token unused for 30 days expires even if the app's policy says it is valid until revoked. Salesforce's Winter '27 release note says enforcement starts in sandboxes on a rolling basis from October 21, 2026 and in production, scratch and Developer Edition orgs from November 4, 2026, and that Salesforce revokes existing access tokens once at enforcement.

Timeline of Salesforce's 30-day refresh token idle limit: sandboxes from October 21, 2026, production from November 4, 2026, with expired tokens returning invalid_grant.

Integrations that run less than monthly, or connections a customer leaves idle, now need a path back to user authorization. Using a refresh token within the 30 days resets the idle clock.

The other cause is the app's Refresh Token Policy. For a connected app, it sits in Setup under Manage Connected Apps, then Edit Policies, then OAuth Policies. For an external client app, it sits on the Policies tab under OAuth Policies, in the App Authorization section, per Salesforce's external client app CLI guide. "Refresh token is valid until revoked" is the default, so a token that expires on a fixed schedule usually means someone changed the policy.

invalid_grant with "authentication failure"

authentication failure usually means the user behind the request can't log in through this app. Salesforce's Industries troubleshooting guide gives the integration user being deactivated, expired or otherwise invalid as the cause. Check the user's status and login history, then the app's Permitted Users policy. An inactive user can also come back as the separate inactive_user code.

invalid_grant with "ip restricted or invalid login hours"

This description means the request came from outside the user's profile login IP ranges or login hours. The connected app's IP Relaxation policy decides whether those ranges are enforced, with options from "Enforce IP restrictions" (the default) to "Relax IP restrictions". The JWT bearer and SAML bearer flows always enforce IP restrictions regardless of that policy, per the connected app OAuth policies page. A cloud provider rotating your egress IPs is a common way to hit this on a connection that used to work.

invalid_grant with "user hasn't approved this consumer"

In the JWT bearer flow, this means the user has neither been pre-authorized by an admin nor approved the app before. Salesforce's JWT bearer flow guide says to use profiles and permission sets when the policy is admin approved users are pre-authorized, or end-user approval when users may self-authorize. Also check the username in the assertion for typos and whether you are sending a sandbox user to the production host.

invalid_grant with "audience is invalid"

The JWT's aud claim must be the authorization server URL, which is https://login.salesforce.com, https://test.salesforce.com or an Experience Cloud site URL, per the JWT bearer flow guide. Salesforce allows a 3-minute buffer for clock skew on the token's timestamps.

invalid_grant from a PKCE code_verifier

A code_verifier that isn't the valid verifier for the code_challenge you sent comes back as invalid_grant, not as a PKCE-specific error, per the authorization errors page. A malformed code_challenge on the authorize call returns invalid_request instead.

invalid_grant from the client credentials flow

The client credentials flow returns invalid_grant when the request goes to https://login.salesforce.com or https://test.salesforce.com. Salesforce's errors page says to use your My Domain URL for this flow. The flow also needs an integration user set as the run-as user, which must have the API Only permission according to the external client app OAuth policies metadata. This flow doesn't issue refresh tokens.

invalid_grant from the hybrid app refresh token flow

If an external client app issues JWT-based access tokens, the hybrid app refresh token flow returns invalid_grant on a token request. Salesforce's hybrid app refresh token flow page says refresh token rotation in that flow works only with opaque access tokens, so the fix is the token format, not the request.

redirect_uri_mismatch means the callback URL isn't registered

redirect_uri_mismatch means the redirect_uri your client sent doesn't match any value in the app's Callback URL field. Salesforce's web server flow guide says the redirect URI must match one of those values and must be URL encoded. redirect_uri_missing means the parameter wasn't sent at all, often because a proxy dropped it.

The usual differences are a trailing slash on one side only, http where the app has https, or a callback from a different environment. Add every environment's callback to the same app instead of keeping several apps in step. Existing connected apps stay editable after the Spring '26 creation change.

INVALID_SESSION_ID means the access token is no longer valid

INVALID_SESSION_ID comes back from an API call, not from the token endpoint. Salesforce's SOAP API reference says the session ID is malformed or has expired, and the REST API returns a 401 when the session ID or OAuth token has expired or is invalid.

CauseFix
The access token expired after the session timeoutRefresh it
The app's access or the token was revokedRe-authorize
The token is sent to a host other than the org's instanceUse the instance_url returned with the token

Treat INVALID_SESSION_ID as a normal signal. Catch it, refresh once, retry the call once, and only then surface a failure. If the app uses refresh token rotation, save the new refresh token from every refresh, because the old one stops working, and make sure two workers don't refresh the same connection at once. Salesforce's ISV security requirements warn that parallel refresh requests can race.

invalid_client and invalid_client_id

invalid_client_id means the client identifier (consumer key) is wrong, and invalid_client means the client secret is wrong or was rotated. invalid_client with app must be installed into org is the uninstalled-app restriction described in the OAUTH_APPROVAL_ERROR_GENERIC section, not a secret problem. Salesforce's Industries troubleshooting guide also lists invalid_client_id after a sandbox refresh, when the app's credentials in the sandbox no longer match what the client sends.

Edge cases that break Salesforce OAuth connections

These Salesforce OAuth failure modes are documented by Salesforce but rarely covered in troubleshooting guides, and they tend to surface weeks after a connection goes live.

  • The 30-day limit starts with a one-time revocation. When Salesforce enforces the idle refresh token limit, it revokes existing access tokens once, per the Winter '27 release note. Every connection then refreshes at the same moment, so a client that refreshes all customers in a burst can trip rate_limit_exceeded.
  • Reusing a rotated refresh token kills the whole chain. With refresh token rotation on, a client that presents a refresh token that was already rotated out makes Salesforce invalidate the current refresh token and its access tokens. The user has to authorize again, per the hybrid app refresh token flow page. Two workers refreshing the same connection is the usual way this happens.
  • Cloned admin profiles don't get the new permission. "Approve Uninstalled Connected Apps" is assigned automatically only to the System Administrator standard profile, so an integration user on a profile cloned from it still hits OAUTH_APPROVAL_ERROR_GENERIC, per the usage restrictions notice.
  • Device flow users weren't grandfathered. Users who authorized an uninstalled app before September 2025 keep access, except when the app uses the OAuth 2.0 device flow.
  • Switching Permitted Users cuts off existing users. Changing a connected app to "Admin approved users are pre-authorized" removes access for anyone whose profile or permission set isn't added, per the connected app OAuth policies page.
  • JWT and SAML bearer flows ignore IP Relaxation. Both always enforce the user's profile IP ranges, so relaxing IP restrictions on the app doesn't fix ip restricted errors in a server-to-server integration.
  • An org admin's policy wins over your app settings. For external client apps, policies apply only in the org where they are set, and an admin's values persist even when the developer updates the app's settings, per Configure OAuth Policies.
  • Authorization codes expire after 15 minutes. A slow or queued token exchange in the web server flow returns invalid_grant for an invalid authorization code, per the web server flow guide.

All Salesforce OAuth error codes in one table

These are the codes on Salesforce's OAuth 2.0 Authorization Errors page, with what each usually means in practice.

ErrorWhat Salesforce saysWhat it usually means
invalid_grantMany causes, see the error_descriptionRead the description, then the sections above
invalid_clientClient secret is invalidWrong or rotated secret, or "app must be installed into org"
invalid_client_idClient identifier is invalidWrong consumer key, or a sandbox refresh
redirect_uri_mismatchRedirect URI mismatch with connected app definitionCallback URL not registered exactly
redirect_uri_missingRedirect URI not providedThe parameter was dropped
invalid_requestHTTPS required, wrong HTTP method, invalid code_challenge, unsupported parametersA malformed request
invalid_scopeThe requested scope is invalid, unknown or malformedA scope the app doesn't have
invalid_app_accessUser isn't approved by an admin to access this appAdmin approved policy without the user's profile
inactive_userUser is set to inactive by the org's adminThe integration user was deactivated
inactive_orgOrg is locked, closed or suspendedThe org itself is unavailable
access_deniedUser denied access to the client appThe user clicked Deny
rate_limit_exceededNumber of login attempts has been exceededUsually a client requesting tokens in a loop
server_errorAuthorization requests exceed the hourly limitToo many authorize calls from the app

Keeping Salesforce OAuth working across your customers' orgs

SaaS products that connect to their customers' Salesforce orgs see Salesforce OAuth errors in orgs they don't administer, and each one stalls a customer's onboarding or a sync they depend on.

Every setting in this guide is set per customer org. Each customer's admin decides whether your app is installed, who the Permitted Users are, which IP ranges apply and how long refresh tokens live. A customer whose connection sits unused for 30 days now loses its refresh token. And if you list your app on AppExchange, Salesforce's security requirements for partners require PKCE, refresh token rotation, a 30-day idle refresh token limit and a refresh token IP allowlist, all due May 11, 2026.

That multi-customer version is an integration problem, and it is the kind of work Appnigma does. With Appnigma's integration infrastructure, your engineers build the integration while Appnigma handles app registration, customer authorization and monitoring for each customer connection. If you'd rather not build it in-house, Appnigma's done for you engineers build and maintain the integration in your codebase. If your app needs to live inside Salesforce, Appnigma's marketplace apps team builds the managed package and supports the security review.

Frequently Asked Questions

What does OAUTH_APPROVAL_ERROR_GENERIC mean in Salesforce?

The connected app isn't installed in the user's org and the user lacks "Approve Uninstalled Connected Apps", a restriction enforced since September 2025. An admin installs the app from Connected Apps OAuth Usage or grants the permission.

How do I fix invalid_grant authentication failure in Salesforce?

Check that the integration user is active, that Permitted Users allows that user, and that you call the right host for production or sandbox. The client credentials flow needs your My Domain URL.

Why does my Salesforce refresh token keep expiring?

Since Winter '27, refresh tokens unused for 30 days expire, enforced in production from November 4, 2026. A fixed-schedule expiry means the Refresh Token Policy was changed from the default, valid until revoked.

How do I fix redirect_uri_mismatch in Salesforce?

Send a redirect_uri that matches one of the app's Callback URL values exactly, URL encoded. Check trailing slashes, http versus https and the environment.

What causes INVALID_SESSION_ID in the Salesforce API?

The access token on the API call expired or was revoked. Refresh once, retry once and use the instance_url returned with the token.

Can Appnigma handle Salesforce OAuth for our customers' orgs?

Yes. Appnigma's integration infrastructure handles app registration, customer authorization and per-customer monitoring for SaaS products that connect to customers' Salesforce orgs, and Appnigma's done for you engineers can build and maintain that integration for you.

Sources

  1. OAuth 2.0 Authorization Errors, Salesforce Help
  2. Prepare for Salesforce Connected App Usage Restrictions Change and New Connected Apps Can No Longer Be Created in Spring '26, Salesforce Help
  3. Refresh Token Idle TTL Is Limited to 30 Days, Salesforce Winter '27 release notes
  4. Manage OAuth Access Policies for a Connected App and Create an External Client App, Salesforce
  5. OAuth 2.0 JWT Bearer Flow, Web Server Flow and Hybrid App Refresh Token Flow, Salesforce Help
  6. Secure Your Connected Apps and External Client Apps, ISVforce Guide
  7. SOAP API ExceptionCode and REST API Status Codes, Salesforce Developers
  8. Communications Cloud troubleshooting and ExtlClntAppOauthConfigurablePolicies, Salesforce Developers

Documentation checked October 23, 2026.

Which integration is your next deal waiting on?

Bring the customer requirements and your current setup. Get a clear scope and delivery timeline to take back to them.

© 2026 Appnigma AI. Built by ex-Salesforce engineers.