kevinohara80 / nforce

nforce is a node.js salesforce REST API wrapper for force.com, database.com, and salesforce.com
MIT License
474 stars 167 forks source link

Autorefresh doesn't seem to work, get INVALID_SESSION_ID #69

Closed eliasdawson closed 10 years ago

eliasdawson commented 10 years ago

My app is working great for getting data into Salesforce and this library has made it much easier, however, my session is expiring so when I leave it running overnight, I start getting a 401 response.

{
    "errorCode": "INVALID_SESSION_ID",
    "messageBody": "Session expired or invalid",
    "statusCode": 401
}

I have autoRefresh set to true in the options to createConnection. When I'm debugging locally, opts.oauth.refresh_token is undefined in _apiRequest on line 755. Any ideas? Is there another step to get autoRefresh working?

kevinohara80 commented 10 years ago

Three things to check.

  1. Make sure you are authenticating with the authorization code/web server flow
  2. Make sure your connected app defines scopes of at least refresh_token.
  3. Make sure your nforce call to getAuthUri is passing the right scopes.

More info on the scopes here

eliasdawson commented 10 years ago

Thanks for your help. I'm pretty sure I'm doing user authentication, and the issue isn't in the code.