5

Is anyone else having problems with Plaid's linkTokenCreate method? I'm using node.js as the backend and when I run it alongside the frontend, the error starts on the line involving this function.

Even when I use the standard quickstart options, I still get the same 400 bad request error.

This is the backend code, same as the quickstart. I'm just testing for the link token, so its the only route I've defined.

app.post('/create_link_token', function (request, response, next)  {
    console.log('HI THERE')
    Promise.resolve()
    .then(async function () {
        const configs = {
            user: {
                //this should be a unique id for the current user.
                client_user_id: 'user-id',
            },
            client_name: 'Plaid Quickstart', 
            products: PLAID_PRODUCTS, 
            country_codes: PLAID_COUNTRY_CODES, 
            language: 'en',
        };

        console.log(configs);

        // if (PLAID_REDIRECT_URI !== '') {
        //     configs.redirect_uri = PLAID_REDIRECT_URI;
        // };

        const createTokenResponse = await client.linkTokenCreate(configs);
        console.log(createTokenResponse);
        prettyPrintResponse(createTokenResponse);
        response.json(createTokenResponse.data);
        
    })
    .catch(next);
});

and this is the error:

Error: Request failed with status code 400
    at createError (C:\Users\MyComputer\Desktop\mukadi\plaid-integration\backend\node_modules\axios\lib\core\createError.js:16:15)
    at settle (C:\Users\MyComputer\Desktop\mukadi\plaid-integration\backend\node_modules\axios\lib\core\settle.js:17:12)
    at IncomingMessage.handleStreamEnd (C:\Users\MyComputer\Desktop\mukadi\plaid-integration\backend\node_modules\axios\lib\adapters\http.js:269:11)      
    at IncomingMessage.emit (node:events:402:35)
    at endReadableNT (node:internal/streams/readable:1343:12)
    at processTicksAndRejections (node:internal/process/task_queues:83:21)

3 Answers3

3

Might be silly - but when I got this exact error it was because we didn't register our URI in our plaid dashboard.

Register your redirect URI:

Sign in to the Plaid Dashboard and go to the Team Settings -> API page. Next to Allowed redirect URIs click Configure then Add New URI. Enter your redirect URI, which you must also set up as a Universal Link for your application, for example: https://app.example.com/plaid/. Click Save Changes.

Emily
  • 100
  • 11
1

Probably an issue with your .env file. Did you check the logs? https://dashboard.plaid.com/activity/logs should show you the request and have details of the error.

Alex
  • 1,245
  • 1
  • 9
  • 10
  • I wish, though I've looked over my env, and everything in there is set up correctly. And since a link was never established (I guess) nothing is showing up in the logs either. – workinprogress98 Jul 27 '22 at 12:55
  • If there is no error on the dashboard logs, then your request did not reach Plaid's servers with your client ID. Perhaps take a look at the request that is actually being sent using logging or a request inspection tool. – Alex Jul 27 '22 at 17:14
0

It could be also the version of the API

Initiate your API with a version, Java for example:

apiKeys.put("plaidVersion", "2020-09-14");
Michael P
  • 41
  • 6