Last active
March 22, 2016 17:34
-
-
Save Ergin008/0295f97ead686693a4e1 to your computer and use it in GitHub Desktop.
code snippets that shows how to call the Login API using DocuSign-node NPM client
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var docusign = require('docusign-esign'); | |
var async = require('async'); | |
var integratorKey = '[INTEGRATOR_KEY]', // Integrator Key associated with your DocuSign Integration | |
email = '[EMAIL]', // Email for your DocuSign Account | |
password = '[PASSWORD]', // Password for your DocuSign Account | |
recipientName = '[RECIPIENT_NAME]', // Recipient's Full Name | |
recipientEmail = '[RECIPIENT_EMAIL]'; // Recipient's Email | |
var basePath = "https://demo.docusign.net/restapi"; | |
// initialize the api client | |
var apiClient = new docusign.ApiClient(); | |
apiClient.setBasePath(basePath); | |
// create JSON formatted auth header | |
var creds = JSON.stringify({ | |
Username: email, | |
Password: password, | |
IntegratorKey: integratorKey | |
}); | |
// configure DocuSign authentication header | |
apiClient.addDefaultHeader("X-DocuSign-Authentication", creds); | |
// assign api client to the Configuration object | |
docusign.Configuration.default.setDefaultApiClient(apiClient); | |
async.waterfall([ | |
function login (next) { | |
// login call available off the AuthenticationApi | |
var authApi = new docusign.AuthenticationApi(); | |
// login has some optional parameters we can set | |
var loginOps = new authApi.LoginOptions(); | |
loginOps.setApiPassword("true"); | |
loginOps.setIncludeAccountIdGuid("true"); | |
authApi.login(loginOps, function (err, loginInfo, response) { | |
if (err) { | |
return next(err); | |
} | |
if (loginInfo) { | |
// list of user account(s) | |
// note that a given user may be a member of multiple accounts | |
var loginAccounts = loginInfo.getLoginAccounts(); | |
console.log("LoginInformation: " + JSON.stringify(loginAccounts)); | |
next(null, loginAccounts); | |
} | |
}); | |
} | |
]); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment