Restforce Salesforce REST API INVALID_SESSION_ID: Session expired or invalid

953 Views Asked by At

I am using the Rails Restforce gem to connect to my app to Salesforce.

I am able to authenticate without issue and make calls to add/delete records. However after some period of time (many hours), I begin to get:

Restforce::UnauthorizedError: INVALID_SESSION_ID: Session expired or invalid

From my understanding the Restforce gem should handle getting a new token automatically. Here is how I am connecting:

@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 }

Any idea what I am doing wrong?

Update: here are the app permission settings. To confirm I am able to do what I need via the API, but the session expires after a day or so.

enter image description here

0

There are 0 best solutions below