0
votes

I'm using the official Plaid Java API to make a demo application. I've got the back end working in Sandbox, with their /sandbox/public_token/create generated public keys.

Now, I'm trying to modify the front-end from Plaid's quickstart project to talk with my back end, so I can start using the development tier to work with my IRL bank account.

I'm implementing the basic first step - generating a link_token. However, when the front end calls my controller, I get the following error:

ErrorResponse{displayMessage='null', errorCode='INVALID_FIELD', errorMessage='client_id must be a properly formatted, non-empty string', errorType='INVALID_REQUEST', requestId=''}

This is my current iteration on trying to generate a link_token:

public LinkTokenResponse generateLinkToken() throws IOException {
    List<String> plaidProducts = new ArrayList<>();
    plaidProducts.add("transactions");
    List<String> countryCodes = new ArrayList<>();
    countryCodes.add("US");
    countryCodes.add("CA");

    Response<LinkTokenCreateResponse> response =
            plaidService.getClient().service().linkTokenCreate(new LinkTokenCreateRequest(
                    new LinkTokenCreateRequest.User("test_user_ID"),
                    "test client",
                    plaidProducts,
                    countryCodes,
                    "en"
            ).withRedirectUri("")).execute();
    try {
        ErrorResponse errorResponse = plaidService.getClient().parseError(response);
        System.out.println(errorResponse.toString());
    } catch (Exception e) {
        // deal with it. you didn't even receive a well-formed JSON error response.
    }
    return new LinkTokenResponse(response.body().getLinkToken());
}

I modeled this after how it seems to work in the Plaid Quickstart's example. I do not see client ID being set explicitly anywhere in there, or anywhere else in Plaid's Java API. I'm at a bit of a loss.

1

1 Answers

0
votes

I'm not super familiar with the Java Plaid library specifically, but when using the Plaid client libraries, the client ID is generally set when initializing the client instance. From there, it is automatically included in any calls you make from that client.

You can see the client ID being set in the Java Quickstart here: https://github.com/plaid/quickstart/blob/master/java/src/main/java/com/plaid/quickstart/QuickstartApplication.java#L67

PlaidClient.Builder builder = PlaidClient.newBuilder()
      .clientIdAndSecret(configuration.getPlaidClientID(), configuration.getPlaidSecret());
    switch (configuration.getPlaidEnv()) {
    case "sandbox":
      builder = builder.sandboxBaseUrl();
      break;
    case "development":
      builder = builder.developmentBaseUrl();
      break;
    case "production":
      builder = builder.productionBaseUrl();
      break;
    default:
      throw new IllegalArgumentException("unknown environment: " + configuration.getPlaidEnv());
    }
    PlaidClient plaidClient = builder.build();