This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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() { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |