Home » Java » Error while requesting an access token. No accessTokenResponse object recieved, maybe a non HTTP 200 received?

Error while requesting an access token. No accessTokenResponse object recieved, maybe a non HTTP 200 received?

Posted by: admin October 29, 2018 Leave a comment

Questions:

I was following this tutorial: https://developers.docusign.com/esign-rest-api/code-examples/config-and-auth
(I used java)

In the third step  I dont know how to get the code that is sent back form DocuSign as query param in the redirect uri:

// Java request auth token
**String code = "{ENTER_AUTH_CODE_FROM_PREVIOUS_STEP}";**
// 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();

I get an error saying the requested access token is null. Below is the error:

Error while requesting an access token. No accessTokenResponse object received, maybe a non HTTP 200 received?

Has anybody ever got the same one or could maybe someone tell me how to fix it.

Answers: