heroku/databasedotcom — Issue #42: Getting "SESSION_EXPIRED" or "NOT_FOUND" errors when using as 2nd user
Author: mwelchwt
Created: 2011-12-08 22:44:38+00:00
State: open

I'm using the gem to reach in to salesforce and pull out some attachment bodies. My basic flow is this:

1: POST to Sinatra REST service from SFDC, sending a JSON body containing attachment ids, as well as a session token for authentication.
2: In Sinatra app, immediately turn around and try grabbing the name of the first included attachment from SFDC, using the token and the token/instance name authentication method of the gem.
3: If (2) worked, queue a delayed job to grab all the attachment bodies and act them.
4: Return a "successfully queued" JSON body to SFDC callout.

Everything works great when executed as the first user. If I log in to SFDC as another user, and try the same thing, I get an error_code of "SESSION_INVALID" or "NOT_FOUND" for that step #2. There doesn't seem to be any rhyme or reason to which I get.

I've confirmed that the 2nd user can get back in to SFDC by calling an Apex REST service directly, skirting the DBDC gem, so I'm not sure why that step #2, using the gem, doesn't work for anyone but the first user after a restart of the ruby app.