Skip to content

Instantly share code, notes, and snippets.

@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";