Skip to content

Instantly share code, notes, and snippets.

@Ergin008
Last active September 5, 2016 06:28
Show Gist options
  • Save Ergin008/0761bef67bc0927b463d to your computer and use it in GitHub Desktop.
Save Ergin008/0761bef67bc0927b463d to your computer and use it in GitHub Desktop.
code snippet that shows the Login API
// Download API Client and add to your project:
// https://github.com/docusign/docuSign-java-client
import com.docusign.esign.api.*;
import com.docusign.esign.client.*;
import com.docusign.esign.model.*;
// Enter your DocuSign credentials
String UserName = "[EMAIL]";
String Password = "[PASSWORD]";
String IntegratorKey = "[INTEGRATOR_KEY]";
// for production environment update to "www.docusign.net/restapi"
String BaseUrl = "https://demo.docusign.net/restapi";
// initialize the api client for the desired environment
ApiClient apiClient = new ApiClient();
apiClient.setBasePath(BaseUrl);
// create JSON formatted auth header
String creds = "{\"Username\":\"" + UserName + "\",\"Password\":\"" + Password + "\",\"IntegratorKey\":\"" + IntegratorKey + "\"}";
apiClient.addDefaultHeader("X-DocuSign-Authentication", creds);
// assign api client to the Configuration object
Configuration.setDefaultApiClient(apiClient);
try
{
// login call available off the AuthenticationApi
AuthenticationApi authApi = new AuthenticationApi();
// login has some optional parameters we can set
AuthenticationApi.LoginOptions loginOps = authApi.new LoginOptions();
loginOps.setApiPassword("true");
loginOps.setIncludeAccountIdGuid("true");
LoginInformation loginInfo = authApi.login(loginOps);
// note that a given user may be a member of multiple accounts
List<LoginAccount> loginAccounts = loginInfo.getLoginAccounts();
System.out.println("LoginInformation: " + loginAccounts);
}
catch (com.docusign.esign.client.ApiException ex)
{
System.out.println("Exception: " + ex);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment