Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Handle case when session is not valid for use with the REST API #1301

Open
wants to merge 2 commits into
base: issue-1291
Choose a base branch
from

Conversation

qbert-007
Copy link

When Session Security Level Required at Login is set to High Assurance level in the user's profile.
And below default setting is set for session security level:
image

Salesforce throws below error when doing query call:

{
  statusCode: 401,
  headers: {
    "cache-control": "no-cache,must-revalidate,max-age=0,no-store,private",
    connection: "close",
    "content-type": "application/json;charset=UTF-8",
    date: "Fri, 06 Jan 2023 09:33:41 GMT",
    "set-cookie": "CookieConsentPolicy=0:1; path=/; expires=Sat, 06-Jan-2024 09:33:41 GMT; Max-Age=31536000, LSKey-c$CookieConsentPolicy=0:1; path=/; expires=Sat, 06-Jan-2024 09:33:41 GMT; Max-Age=31536000, BrowserId=NNa2EI2lEe2R9MHZgNtMtQ; domain=.salesforce.com; path=/; expires=Sat, 06-Jan-2024 09:33:41 GMT; Max-Age=31536000",
    "strict-transport-security": "max-age=63072000; includeSubDomains",
    "transfer-encoding": "chunked",
    "x-content-type-options": "nosniff",
    "x-robots-tag": "none",
    "x-xss-protection": "1; mode=block",
  },
  body: "[{\"message\":\"This session is not valid for use with the REST API\",\"errorCode\":\"INVALID_SESSION_ID\"}]",
}

To handle this, we need to check whether the session is recoverable before re-sending request with refreshed token. Else it get stuck in circular pattern by sending request again and again with refreshed token.

Related issue: #1291

@dtto86
Copy link

dtto86 commented Mar 6, 2023

We faced same issue when our NodeJs script called describeGlobal() of jsForce v1.11.x. In User's profile, we set Session Security Level Required at Login to High Assurance and under Session Security levels, Multi-factor authentication was added in High Assurance input box.

From logs, we could see that POST call to /services/Soap/u/54.0 API returned 200 status code but GET call to /services/data/v54.0/sobjects API failed with 401 status code. Here, jsForce library makes infinite calls to /services/data/v54.0/sobjects API but failed to return any callback response.

@stomita Please let us know if fix for this issue is available in 1.x.x/2.x.x version.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants