kdcllc / CometD.NetCore.Salesforce

CometD Salesforce Implementation.
MIT License
45 stars 24 forks source link

Add support for handling 401 Authentication Errors from Salesforce #23

Closed apaulro closed 3 years ago

apaulro commented 3 years ago

Per the section noted here, this client needs to support the scenario when BayeuxClient receives an error value of 401::Authentication invalid : https://developer.salesforce.com/docs/atlas.en-us.api_streaming.meta/api_streaming/streaming_handling_errors.htm

401 Authentication Errors

Client authentication can sometimes become invalid, for example, when the OAuth token is revoked or a Salesforce admin revokes the Salesforce session. An admin can revoke an OAuth token or delete a Salesforce session to prevent a client from receiving events. Sometimes a client can inadvertently invalidate its authentication by logging out from a Salesforce session. Streaming API regularly validates the OAuth token or session ID while the client is connected. If client authentication is not valid, the client is notified with an error. A Bayeux message is sent on the /meta/connect channel with an error value of 401::Authentication invalid and an advice field containing reconnect=none. After receiving the error notification in the channel listener, the client must reauthenticate and reconnect to receive new events.
kdcllc commented 3 years ago

@apaulro would you be interested in PR for this feature?

apaulro commented 3 years ago

@kdcllc - https://github.com/kdcllc/CometD.NetCore.Salesforce/pull/29 submitted

kdcllc commented 3 years ago

@apaulro thanks for the PR!