Skip to content

Instantly share code, notes, and snippets.

@Ergin008
Last active July 9, 2016 02:15
Show Gist options
  • Save Ergin008/57455bbeea3eee95cfc7 to your computer and use it in GitHub Desktop.
Save Ergin008/57455bbeea3eee95cfc7 to your computer and use it in GitHub Desktop.
code snippet that shows how to Login using DocuSign .NET client
// Download API Client and add to your project:
// https://github.com/docusign/docusign-csharp-client
using DocuSign.eSign.Api;
using DocuSign.eSign.Model;
using DocuSign.eSign.Client;
// Enter your credentials
string Username = "[EMAIL]";
string Password = "[PASSWORD]";
string IntegratorKey = "[INTEGRATOR_KEY]";
// set demo (aka test) environment (for production change to www.docusign.net/restapi)
string basePath = "https://demo.docusign.net/restapi";
// instantiate a new api client and set desired environment
ApiClient apiClient = new ApiClient(basePath);
// set client in global config so we don't have to pass it to each API object.
Configuration.Default.ApiClient = apiClient;
// create JSON formatted auth header containing Username, Password, and Integrator Key
string authHeader = "{\"Username\":\"" + Username + "\", \"Password\":\"" + Password + "\", \"IntegratorKey\":\"" + IntegratorKey + "\"}";
Configuration.Default.AddDefaultHeader("X-DocuSign-Authentication", authHeader);
// the authentication api uses the apiClient (and X-DocuSign-Authentication header) that are set in Configuration object
AuthenticationApi authApi = new AuthenticationApi();
LoginInformation loginInfo = authApi.Login();
Console.WriteLine("LoginInformation: {0}", loginInfo.ToJson());
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment