3

I am attempting to set up Plaid in my app, and am following the Quickstart guide for Node.js and Express. When I call the client.linkTokenCreate function I am getting a status 400 Bad Request response. I believe my code exactly matches the quickstart, and I am using sandbox mode, so I am unsure where I am going wrong.


const { Configuration, PlaidApi, PlaidEnvironments, Products, CountryCode } = require("plaid");

const configuration = new Configuration({
basePath: PlaidEnvironments[process.env.PLAID_ENV],
baseOptions: {
 headers: {
   "PLAID-CLIENT-ID": process.env.PLAID_CLIENT_ID,
   "PLAID-SECRET": process.env.PLAID_SECRET,
 },
},
});
console.log(configuration)
const client = new PlaidApi(configuration);

router.post("/create_link_token", async (req, res)  => {
// Get the client_user_id by searching for the current user
// const user = await User.find(...);
// const clientUserId = user.id;
const request = {
 user: {
   // This should correspond to a unique id for the current user.
   client_user_id: "test123",
 },
 client_name: "Name Of App",
 products: [Products.Auth],
 language: "en",
  webhook: 'https://app.com',
 country_codes: [CountryCode.Us],
};
try {
 console.log("request",process.env.PLAID_CLIENT_ID,process.env.PLAID_SECRET)
 const createTokenResponse = await client.linkTokenCreate(request);
 console.log("createTokenResponse", createTokenResponse);
 res.status(200).json(createTokenResponse);
} catch (error) {
 console.log("error", error.message)
 res.send(error.message)
}
});
ethanj
  • 31
  • 3
  • Can you provide the exact request as reported by your logging (with the client ID and secret redacted) as well as the exact response? Having that detail will be really helpful for contributors to understand what might be going wrong. – Alex Nov 30 '21 at 23:38
  • 1
    @Alex My mistake on the title. The exact log I get is "request _client id_ _plaid secret_" "error Request failed with status code 400" I don't get any logging from the line console.log("createTokenResponse", createTokenResponse); because the function errors on the client.linkTokenCreate(request) function I believe. I meant 400 in the title, not 404. – ethanj Dec 01 '21 at 15:10
  • Do you have any more details about the exact request body you are sending, as well as the exact error? If you don't have the error in your logs, you can check logs on your browser devtools. There should also be error details about any API requests on the Plaid Dashboard in the Activity->Logs section. – Alex Dec 01 '21 at 21:02
  • @ethanj try removing the webhook, it worked for me when I tried it. – Krusty the Clown May 02 '22 at 19:36
  • 2
    I was also having a 400 issue and had to add my URL (in this case for sandbox `http://localhost:3000/`) to the "Allowed redirect URIs" underneath "API" in the plaid dashboard. – nf071590 Oct 22 '22 at 17:37

0 Answers0