You need to sign in to do that
Don't have an account?

INVALID_SESSION_ID: Session expired or invalid
Hello,
I've seen this topic come up, but I don't see any answers that seem to be relevant to my case.
I am using the Rails restforce Gem to connect to Salesforce. I am able to connect, pull, update, create data, but after some period of time my session seems to expire with the message "INVALID_SESSION_ID: Session expired or invalid".
Here is the code I am using to initialize my client:
And when I make a request (again after a period of time) I get the following back:
Any pointers would be greatly appreciated!
I've seen this topic come up, but I don't see any answers that seem to be relevant to my case.
I am using the Rails restforce Gem to connect to Salesforce. I am able to connect, pull, update, create data, but after some period of time my session seems to expire with the message "INVALID_SESSION_ID: Session expired or invalid".
Here is the code I am using to initialize my client:
@client = Restforce.new oauth_token: options[:salesforce_token], refresh_token: options[:salesforce_refresh_token], instance_url: options[:salesforce_instance_url], client_id: sales_force_client_id, client_secret: sales_force_client_secret, authentication_callback: Proc.new { |x| Rails.logger.debug x.to_s }
And when I make a request (again after a period of time) I get the following back:
url: "https://cs13.salesforce.com/services/data/v38.0/sobjects/Contact" method: :post headers: {"User-Agent"=>"Faraday v0.9.2", "Content-Type"=>"application/json", "Authorization"=>"OAuth XXXXXXXXXXX"} body: "{\"LastName\":\"Test\",\"FirstName\":\"Test \",\"MailingCountry\":\"United States\",\"MailingPostalCode\":\"29464\",\"MailingCity\":\"Mount Pleasant\",\"MailingState\":\"South Carolina\",\"Phone\":\"1-555-555-5555\",\"Business_Contact__c\":true,\"RecordTypeId\":\"01238000000UVfW\"}" D, [2017-02-06T14:43:14.791977 #99698] DEBUG -- response: status: "401" headers: {"date"=>"Mon, 06 Feb 2017 19:43:07 GMT", "x-content-type-options"=>"nosniff", "x-xss-protection"=>"1; mode=block", "content-security-policy"=>"reflected-xss block;report-uri /_/ContentDomainCSPNoAuth?type=xss, referrer origin-when-cross-origin", "set-cookie"=>"BrowserId=I2nltdq0SSqJ7KinYQEyMw;Path=/;Domain=.salesforce.com;Expires=Fri, 07-Apr-2017 19:43:07 GMT", "expires"=>"Thu, 01 Jan 1970 00:00:00 GMT", "www-authenticate"=>"Token", "content-type"=>"application/json;charset=UTF-8", "transfer-encoding"=>"chunked", "connection"=>"close"} body: "[{\"message\":\"Session expired or invalid\",\"errorCode\":\"INVALID_SESSION_ID\"}]"
Any pointers would be greatly appreciated!
Apps -> Manage -> Edit -> Session Policies.
Refresh Token policy is "Refresh token is valid until revoked"
If you happened to resolve this issue, please share the root cause.
Thanks.