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

Session expired or invalid #56

Open
chripede opened this issue Dec 2, 2020 · 2 comments
Open

Session expired or invalid #56

chripede opened this issue Dec 2, 2020 · 2 comments

Comments

@chripede
Copy link
Contributor

chripede commented Dec 2, 2020

When using this to bulk send data (one item at a time) I am hit with

Exception: [{'message': 'Session expired or invalid', 'errorCode': 'INVALID_SESSION_ID'}]

regularly.

For each request I do with SalesforceClient as client so there is no way it will actually expire, unless it does within a second?

@caffalaughrey
Copy link
Collaborator

The extent to which the client currently manages the session is:

  • assign the access_token from a successful login request
  • reuse it for all subsequent requests

To handle your scenario where session timeout is a factor and a fresh session id is needed, we would need to support the refresh token flow. I'd be open to it

@ericbn
Copy link
Contributor

ericbn commented Apr 27, 2023

I had "INVALID_SESSION_ID: Session expired or invalid" errors before, and found out the root cause was having concurrent sessions and one of them calling logout() while the other sessions were still in use, and this invalidated them. Also, if you're using Client as a context manager, logout() will be called when the context exists.

See https://developer.salesforce.com/forums/?id=906F00000005LQoIAM

Never had a single INVALID_SESSION_ID again after I stopped calling logout() or using Client as a context manager.

Given this, I'd say that logout() is evil and should never be called. Automatically refreshing the token would be hiding the issue, so I'm not if favor of adding that feature.

* By "using Client as a context manager" I mean:

with sfdc.client(**client_args) as client:
    ...

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

No branches or pull requests

3 participants