Guest User

Untitled

a guest
Jan 16th, 2019
417
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.96 KB | None | 0 0
  1. var username = "myusername";
  2. var password = "password";
  3.  
  4.  
  5. var conn = new sf.Connection({
  6. oauth2: {
  7. clientId: 'clientID',
  8. clientSecret: 'SecretID',
  9. redirectUri: 'MyRedirectURl'
  10. },
  11. instanceUrl: 'InstanceUrl',
  12. accessToken: 'accestoken',
  13. //this refresh token i am generating for the first time from the POSTMAN
  14. refreshToken: 'my token'
  15. });
  16.  
  17. conn.on("refresh", function (accessToken, res) {
  18. console.log('---res-refresh token');
  19. // Refresh event will be fired when renewed access token
  20. // to store it in your storage for next request
  21. });
  22.  
  23.  
  24. conn.login(username, password, function (err, userInfo) {
  25. if (err) {
  26. console.error(err);
  27. return callback(err);
  28. }
  29. // Now you can get the access token and instance URL information.
  30. // Save them to establish connection next time.
  31. authCreds.accessToken = conn.accessToken;
  32. authCreds.instanceUrl = conn.instanceUrl;
  33.  
  34. // ...
  35. return callback();
  36. });
Add Comment
Please, Sign In to add comment