Using JSForce(nodejs), I create a new connection were it will returns accesstoken,Instance_URL and refreshToken and Userdetails. The thing is it returns accesstoken, Instance_URL and Userdetails but not returning refreshToken. can any one please help me solving this.

app.get('/oauth2/callback', function(req, res) {
   var conn = new sf.Connection({ oauth2 : oauth2 });
   var code = req.param('code');
   conn.authorize(code, function(err, userInfo) {
   if (err) { return console.error(err); }
    // Now you can get the access token, refresh token, and instance URL    Blockquoteinformation.
   // Save them to establish connection next time.
      console.log("User ID: " + userInfo.id);
      console.log("Org ID: " + userInfo.organizationId);
   // ...
});   });
  • Did you ever find out why you weren't receiving a refreshToken? I'm having the same issue. – Lee Harrison Jun 4 '15 at 2:41
  • @Lee Harrison, No I'm still facing the same problem, but Please check whether you included "refresh token" scope in your Connected App setting. Have a look here for more details. github.com/jsforce/jsforce/issues/163. In case you solved this issue let me know. – Chandu Jul 16 '15 at 13:23

I solved this issue by including "refresh token" scope in the Connected App setting. and also by replacing the following code.

res.redirect(oauth2.getAuthorizationUrl({scope: 'api id web'})); to res.redirect(oauth2.getAuthorizationUrl({ scope: 'api id web refresh_token' })); or res.redirect(oauth2.getAuthorizationUrl());

Click here for more details. https://github.com/jsforce/jsforce/issues/242

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.