javadocusignapioltu

Error using DocuSign AuthenticationApi.login() for Legacy Authentication - Missing grant_type/code


I'm trying to use the Authentication::login() API call in the DocuSign Java SDK and am receiving an error. Here's some code:

@Component
public class TestClass {

    private ApiClient apiClient;

    public void authenticate() {

        this.apiClient = new ApiClient("account-d.docusign.com", "docusignAccessCode",
                "mySecretIntegratorKey", "myClientSecret");

        final AuthenticationApi authenticationApi = new AuthenticationApi(this.apiClient);

        try {
            // ERROR ON THE LINE BELOW
            final LoginInformation loginInformation = authenticationApi.login();
        } catch (final ApiException e) {
            // do something appropriate
        }
    }
}

The mySecretIntegratorKey and myClientSecret values are not the real values I'm sending in obviously, but the other ones are.

Here is the error I am receiving when making the login() call:

Caused by: org.apache.oltu.oauth2.common.exception.OAuthSystemException: Missing grant_type/code
at com.docusign.esign.client.auth.OAuth$OAuthJerseyClient.execute(OAuth.java:184)
at org.apache.oltu.oauth2.client.OAuthClient.accessToken(OAuthClient.java:65)
at org.apache.oltu.oauth2.client.OAuthClient.accessToken(OAuthClient.java:55)
at org.apache.oltu.oauth2.client.OAuthClient.accessToken(OAuthClient.java:71)
at com.docusign.esign.client.auth.OAuth.updateAccessToken(OAuth.java:92)
... 123 common frames omitted

I realize that this is using the older legacy authentication, however I have a limitation that won't allow me to upgrade to the newer method of authentication until the first of the year. So for now I need to use this legacy method using SDK Version 2.2.1.

Any ideas what I'm doing wrong here? I'm sure it is something simple...

Thank you for your time.


Solution

  • You want to use Legacy authentication?

    In that case you need to make a number of updates to your code.

    From an old Readme:

    String authHeader = "{\"Username\":\"" +  username +
       "\",\"Password\":\"" +  password + 
       "\",\"IntegratorKey\":\"" +  integratorKey + "\"}";
    apiClient.addDefaultHeader("X-DocuSign-Authentication", authHeader);
    

    The authenticationApi.login doe not actually log you in. (!)

    Rather, that method just gives you information about the current user.

    There is no login with the API since it does not use sessions. Instead, credentials are passed with every API call. The credentials can be an Access Token (preferred), or via Legacy Authentication, a name / password / integration key triplet.

    When using Legacy Authentication, the client secret is not used.

    More information: see the Readme section for using username/password in this old version of the repo.