|
// 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"; |
|
|
|
// use demo authentication server (remove -d for production) |
|
String AuthServerUrl = "https://account-d.docusign.com"; |
|
|
|
// point to the demo (sandbox) environment. For production requests your account sub-domain |
|
// will vary, you should always use the base URI that is returned from authentication to |
|
// ensure your integration points to the correct endpoints (in both environments) |
|
String RestApiUrl = "https://demo.docusign.net/restapi"; |
|
|
|
// instantiate the api client and point to auth server |
|
ApiClient apiClient = new ApiClient(AuthServerUrl, "docusignAccessCode", IntegratorKey, ClientSecret); |
|
|
|
// set the base path for REST API requests |
|
apiClient.setBasePath(RestApiUrl); |
|
|
|
// configure the authorization flow on the api client |
|
apiClient.configureAuthorizationFlow(IntegratorKey, ClientSecret, RedirectURI); |
|
|
|
// set as default api client in your configuration |
|
Configuration.setDefaultApiClient(apiClient); |
|
|
|
try { |
|
// get DocuSign OAuth authorization url |
|
String oauthLoginUrl = apiClient.getAuthorizationUri(); |
|
// open DocuSign OAuth login in the browser |
|
System.out.println(oauthLoginUrl); |
|
Desktop.getDesktop().browse(URI.create(oauthLoginUrl)); |
|
} |
|
catch (OAuthSystemException ex) |
|
{ |
|
System.out.println(ex); |
|
} |