Skip to content

Instantly share code, notes, and snippets.

@Ergin008
Ergin008 / soap_embedded_signing.php
Last active February 16, 2018 05:00
SOAP Quickstart Embedded Signing (PHP)
// Construct the recipient token authentication assertion and specify
// ID, start time, method, and domain
$assertion = new RequestRecipientTokenAuthenticationAssertion();
$assertion->AssertionID = guid();
$assertion->AuthenticationInstant = nowXsdDate();
$assertion->AuthenticationMethod = RequestRecipientTokenAuthenticationAssertionAuthenticationMethod::Password;
$assertion->SecurityDomain = "Request Recipient Token Test";
// Construct the URLs based on UserName
$recip = $env->Recipients[0];
@Ergin008
Ergin008 / soap_embedded_signing.cs
Created February 12, 2018 22:07
SOAP Embedded Signing (C#)
// Construct the recipient token authentication assertion
// Specify ID, start time, method and domain
DocuSignWeb.RequestRecipientTokenAuthenticationAssertion assertion
= new DocuSignWeb.RequestRecipientTokenAuthenticationAssertion();
assertion.AssertionID = new Guid().ToString();
assertion.AuthenticationInstant = DateTime.Now;
assertion.AuthenticationMethod
= DocuSignWeb.RequestRecipientTokenAuthenticationAssertionAuthenticationMethod.Password;
assertion.SecurityDomain = "Request Recipient Token Test";
@Ergin008
Ergin008 / soap_create_envelope.php
Created February 12, 2018 21:55
SOAP Create Envelope (PHP)
// Create the recipient
$rcp1 = new Recipient();// First recipient to put in recipient array
$rcp1->UserName = "John Doe";
$rcp1->Email = $Recipient1Email;
$rcp1->Type = RecipientTypeCode::Signer;
$rcp1->ID = "1";
$rcp1->RoutingOrder = 1;
$rcp1->RequireIDLookup = FALSE;
// Specify captive info to embed the recipient
@Ergin008
Ergin008 / soap_create_envelope.cs
Created February 12, 2018 21:54
SOAP Create Envelope (C#)
// Create the recipient
DocuSignWeb.Recipient recipient = new DocuSignWeb.Recipient();
recipient.Email = "Test email";
recipient.UserName = "Testing account";
recipient.Type = DocuSignWeb.RecipientTypeCode.Signer;
recipient.ID = "1";
recipient.RoutingOrder = 1;
// Need to specify captive info to embed the recipient
recipient.CaptiveInfo = new DocuSignWeb.RecipientCaptiveInfo();
@Ergin008
Ergin008 / GetBaseUri.java
Created February 9, 2018 05:50
Get your DocuSign account's base URI and configure api client
AuthenticationApi authApi = new AuthenticationApi(apiClient);
LoginInformation loginInfo = authApi.login();
// note that the user might belong to multiple accounts, here we simply get first
String accountId = loginInfo.getLoginAccounts().get(0).getAccountId();
String baseUrl = loginInfo.getLoginAccounts().get(0).getBaseUrl();
// important: below code is required for production as the account sub-domains vary in the
// live system. We strip the base URI down to the form https://{env}.docusign.net/restapi
// then re-configure the api client with the new base path
@Ergin008
Ergin008 / GetAccessToken.java
Last active February 9, 2018 06:02
Step 2 of DocuSign Auth Code Grant, uses the code that was generated from auth_code request
// Use the authorization code that was added as a query param to the redirect URI.
// from the previous request. You should set up a route that handles the redirect
// and parses the code so you can then pass it to token endpoint:
String code = "{ENTER_YOUR_AUTHORIZATION_CODE}";
// assign it to the token endpoint
apiClient.getTokenEndPoint().setCode(code);
// optionally register to get notified when a new token arrives
apiClient.registerAccessTokenListener(new AccessTokenListener() {
@Ergin008
Ergin008 / GetAuthorizationCode.java
Last active February 9, 2018 20:37
DocuSign API Authorization Code Grant Sample in demo (sandbox) environment.
// integrator keys are created through developer sandbox accounts then migrated
// to your production account when ready. Note that your integrator key also acts
// as your client ID during oauth requests
String IntegratorKey = "{integratorKey}";
// generate a client secret for the integrator key you supply above, again through sandbox admin menu
String ClientSecret = "{clientSecret}";
// must match a redirect URI (case-sensitive) you configured on the key
String RedirectURI = "https://yourapp.com/callback";
@Ergin008
Ergin008 / getRecipientView.js
Last active October 18, 2017 12:02
code snippets that shows how to request a recipient view (signing URL) using the DocuSign Node Client
function requestRecipientView (envelopeId, loginAccounts, next) {
// set where the recipient should be re-directed once they are done signing
const returnUrl = "http://www.docusign.com/developer-center";
var recipientView = new docusign.RecipientViewRequest();
recipientView.setReturnUrl(returnUrl);
recipientView.setUserName("[RECIPIENT_NAME]");
recipientView.setEmail("[RECIPIENT_EMAIL]");
recipientView.setAuthenticationMethod("email");
@Ergin008
Ergin008 / CreateEnvelopeWithEmbeddedRecipient.js
Last active March 22, 2016 17:35
code snippet that shows how to create an envelope with an embedded recipient using the DocuSign Node Client
function createAndSendEnvelopeWithEmbeddedRecipient (loginAccounts, next) {
var fileBytes = null;
try {
var fs = require('fs'),
path = require('path');
// read file from a local directory
fileBytes = fs.readFileSync(path.resolve(__filename + '/..' + SignTest1File));
} catch (ex) {
@Ergin008
Ergin008 / embeddedSigning.js
Last active September 22, 2015 19:29
Full code sample that shows how to embed the document signing flow using the docusign-node client: https://www.npmjs.com/package/docusign-node
// Install NPM package or download source
// https://www.npmjs.com/package/docusign-node
var docusign = require('docusign-node');
var async = require('async');
var assert = require('assert');
var fs = require('fs');
var integratorKey = "INTEGRATOR_KEY";
var email = "EMAIL";