0

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(conn.accessToken);
      console.log(conn.refreshToken);
      console.log(conn.instanceUrl);
      console.log("User ID: " + userInfo.id);
      console.log("Org ID: " + userInfo.organizationId);
   // ...
});   });
2
  • Did you ever find out why you weren't receiving a refreshToken? I'm having the same issue. Jun 4, 2015 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, 2015 at 13:23

1 Answer 1

1

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

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .