Guide Fixing errors

Salesforce invalid_grant: the causes, how to tell them apart and how to fix each

Updated 7 min read By the BAFO team

Short answer: invalid_grant is what Salesforce's token endpoint answers when the grant you present, a refresh token, an authorization code or a signed assertion, cannot be used. One code covers many causes, and the error_description says which: "expired access/refresh token" means the token is finished and the person must sign in again, while "IP restricted or invalid login hours" means a rule of the org refused the request. The two have different fixes: the first needs a new sign-in, the second needs the org's admin.

What invalid_grant means

A tool calls Salesforce's token endpoint to turn something into an access token: an authorization code at the end of a sign-in, a refresh token to renew a session, or a signed assertion in the JWT bearer and SAML flows. When the endpoint refuses, it answers with an error and a description. Salesforce's example for the refresh token flow is:

{"error":"invalid_grant","error_description":"expired access/refresh token"}

invalid_grant is one code with many reasons, and the description is what separates them. Two neighbours are different errors. invalid_client ("Client secret is invalid") and invalid_client_id ("Client identifier is invalid") say that the app's own credentials are wrong, not that the grant is bad. Salesforce also uses invalid_client for an app that is not installed in the org; see the table below.

The causes Salesforce lists

As of October 2026, Salesforce's error table lists these causes under invalid_grant. They are grouped here by what you do about them:

  • The code or token itself. An invalid authorization code. For the refresh token flow, a refresh or access token that has expired.
  • The person. Invalid user credentials, an invalid user, "Authentication failure" (the table gives no more detail) or a user who has not approved the connected app.
  • A rule of the org. "IP restricted or invalid login hours."
  • PKCE. A code_verifier that is invalid (not base64 encoded, for example) or is not the verifier for the code_challenge, or a code_verifier sent when no code_challenge was.
  • Signed assertions. An invalid assertion or audience. Salesforce's JWT example reads "Audience validation failed".
  • Other flows. The device flow, when it is not enabled for the app or Salesforce cannot grant a token. The client credentials flow, when the request goes to login.salesforce.com or test.salesforce.com instead of the org's My Domain URL.

Three look-alikes are separate error codes: inactive_user ("User is set to inactive by the org's admin"), inactive_org ("Org is locked, closed, or suspended") and invalid_app_access ("User isn't approved by an admin to access this app").

Why a refresh token stops working

Salesforce documents several ways a refresh token ends:

  • The app's Refresh Token Policy. It can be valid until revoked (the default), expire immediately, expire if unused for a set time, or expire after a fixed time. Salesforce notes the policy is checked only when the token is used, so it does not cut a session that is already running.
  • A revoke. A user can revoke an app in their personal settings under Advanced User Details > OAuth Connected Apps. An admin can revoke tokens on the user's detail page or on the Connected Apps OAuth Usage page in Setup.
  • The fifth approval. Each connected app allows five unique approvals per user, and after a fifth is made the oldest is revoked. For OAuth 2.0 each refresh token counts as one. A tool that sends the same person through approval again and again pushes its own older grants out. Salesforce's page is about connected apps.
  • Rotation. With refresh token rotation on, each refresh returns a new refresh token and invalidates the old one. If someone presents a rotated-out token, Salesforce invalidates the current refresh token and its access tokens, and the client has to run the sign-in again.
  • Simultaneous refreshes. Identical requests with the same refresh token sent at the same moment fail intermittently, and Login History shows "Failed: Token request is already being processed". Salesforce advises caching and reusing tokens, and retrying if you do send requests together.
  • No refresh token was issued. The web server flow can return one when the request includes the refresh_token or offline_access scope.

Symptom, cause, owner and fix

What Salesforce saysLikely causeWho fixes itWhat to do
expired access/refresh tokenThe refresh token expired or was revoked: the Refresh Token Policy, a revoke by the user or an admin, the fifth approval, or a rotated-out token presented againThe person; the admin if the policy keeps ending tokensSign in to the app again. If it keeps happening, look at the app's Refresh Token Policy and at how often the same person approves the app
IP restricted or IP restricted or invalid login hoursAn IP restriction or the login hours of the org refuse the requestSalesforce adminAdd the caller's address to the allowed ranges, such as those on the user's profile, or change the app's IP Relaxation. Salesforce notes that IP restrictions apply only if they are set on the profile
invalid_app_access ("User isn't approved by an admin to access this app"), or an invalid_grant whose description mentions admin approval, such as "user is not admin approved to access this app" (that wording is not in Salesforce's error table)The app's Permitted Users policy is "Admin approved users are pre-authorized" and this person's profile or permission set is not on the appSalesforce adminAdd the profile or permission set. The steps are in the OAUTH_APPROVAL_ERROR_GENERIC guide
"Authentication failure", "Invalid user credentials", "Invalid user" or "User hasn't approved the connected app"Salesforce's table lists these without a reason: the grant did not authenticateThe person, then the adminSign in again. If it repeats, read the attempt in Login History and ask the admin to check that the user is active and approved for the app
An invalid authorization codeThe authorization code is not valid; Salesforce calls it a short-lived tokenThe tool's developerExchange the code straight away. If the exchange fails, start the sign-in again to get a new code. Check the PKCE values
"Audience validation failed" or invalid assertionThe signed assertion in a JWT bearer or SAML flow is wrongThe tool's developerCorrect the assertion. Salesforce's table also says these flows need a refresh_token scope and an installed, preauthorized app, which arrives as invalid_request
inactive_user or inactive_orgThe user was deactivated, or the org is locked, closed or suspendedSalesforce adminReactivate the user, or ask Salesforce about the org
invalid_client or invalid_client_idThe app's own secret or identifier is wrong or unknown to the org. Salesforce also uses invalid_client with the description "app must be installed into org" for an uninstalled connected app (see the OAUTH_APPROVAL_ERROR_GENERIC guide)The tool's developer; the Salesforce admin for an uninstalled appFix the credentials, or install the app. This is not a problem of the person's own sign-in
"Failed: Token request is already being processed" in Login HistoryThe same refresh token was sent twice at onceThe tool's developerReuse the token you already have instead of sending identical requests at the same moment, as Salesforce advises

The approval page that can come before this step is covered in OAUTH_APPROVAL_ERROR_GENERIC. A different kind of "Salesforce says no" is the daily API allowance, covered in Salesforce API request limits and AI agents.

Frequently asked questions

Does invalid_grant always mean the person has to sign in again?

No. It does when the description says the token is finished: expired or revoked. A deactivated user or a locked org returns the separate codes inactive_user and inactive_org. When it names an IP restriction, login hours or admin approval, an admin change is the cure and the same sign-in may work again afterwards.

Why do I get invalid_grant when the refresh token is set to be valid until revoked?

Reasons Salesforce documents include a revoke by the user or an admin, the limit of five approvals per user for the app, and a rotated-out token presented again; a deactivated user or a locked org returns the separate codes inactive_user and inactive_org. See the section on why a refresh token stops working.

Is invalid_grant the same as invalid_client?

No. invalid_client means the client secret is invalid, and invalid_client_id that the client identifier is invalid. They are about the app's own credentials, and Salesforce also uses invalid_client with the description "app must be installed into org" for an uninstalled connected app. In both cases the person's own sign-in is not the problem.

Should an integration retry after invalid_grant?

Not with the same dead token. A finished grant needs a new sign-in, and a refusal by a rule of the org needs an admin to change the rule.

Where do I see the failed attempt in Salesforce?

In Setup, Login History has a Status column, and Salesforce's refresh token page says a failed request caused by simultaneous refreshes shows there as "Failed: Token request is already being processed". In the person's Advanced User Details > OAuth Connected Apps list, Salesforce updates Use Count and Last Used even when the app failed to log in.

Sources and further reading

Where this page leans on someone else's documentation or standard, it is listed here. Check the release or edition your org runs: official pages change.

Keep reading