• Christian Malpeli
  • NEWBIE
  • 0 Points
  • Member since 2017

  • Chatter
    Feed
  • 0
    Best Answers
  • 1
    Likes Received
  • 0
    Likes Given
  • 2
    Questions
  • 2
    Replies
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:
 
@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!
Hello,

I'm trying to understand the best way to integrate our 3rd party app with Saleforce.com.  We have what I imagine is a pretty common scenario: We have clients who use our app, who would like to sync certain pieces of our app with their Salesforce instance.

What I am trying to really understand is the best way to handle this.  We are a Ruby on Rails platform.  The REST API looks great and makes perfect sense - however when looking into OAuth, there is a requirement for Client Keys:

https://github.com/realdoug/omniauth-salesforce
 
use OmniAuth::Builder do
    provider :salesforce, ENV['SALESFORCE_KEY'], ENV['SALESFORCE_SECRET']
 end

If we are a multi tenant app, do we need to first create some sort of Master account where we get our own credentials/consumer keys, and then have our clients connect to their Salesforce instances using Oauth?

Essentially we'd like to do something like this: https://help.getfeedback.com/customer/portal/articles/1437223

I hope this question makes sense - thanks!

 
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:
 
@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!
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:
 
@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!