Skip to content

Instantly share code, notes, and snippets.

@Ergin008
Last active February 9, 2018 06:02
Show Gist options
  • Save Ergin008/f32b5a186a39d4df262d462c7f6a7f4e to your computer and use it in GitHub Desktop.
Save Ergin008/f32b5a186a39d4df262d462c7f6a7f4e to your computer and use it in GitHub Desktop.
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() {
@Override
public void notify(BasicOAuthToken token) {
System.out.println("Got a fresh token: " + token.getAccessToken());
}
});
// following call exchanges the authorization code for an access code and updates
// the `Authorization: bearer <token>` header on the api client
apiClient.updateAccessToken();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment