Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error when creating a new plaid Client object #345

Closed
thecoolwinter opened this issue Aug 11, 2020 · 5 comments
Closed

Error when creating a new plaid Client object #345

thecoolwinter opened this issue Aug 11, 2020 · 5 comments

Comments

@thecoolwinter
Copy link

I'm running plaid in a node.js 10 environment, in a GCP cloud function. When using the sandbox, my initialization went fine. But, now that I've moved into development mode, the initialization throws this error:

functions: Error: Missing Plaid "secret"
    at new Client (/Users/.../functions/functions/node_modules/plaid/lib/PlaidClient.js:20:11)
    at initPlaid (/Users/.../functions/functions/index.js:36:23)
    at /Users/.../functions/functions/index.js:168:5
    at /usr/local/lib/node_modules/firebase-tools/lib/emulator/functionsEmulatorRuntime.js:583:20
    at /usr/local/lib/node_modules/firebase-tools/lib/emulator/functionsEmulatorRuntime.js:558:19
    at Generator.next (<anonymous>)
    at /usr/local/lib/node_modules/firebase-tools/lib/emulator/functionsEmulatorRuntime.js:8:71
    at new Promise (<anonymous>)
    at __awaiter (/usr/local/lib/node_modules/firebase-tools/lib/emulator/functionsEmulatorRuntime.js:4:12)
    at runFunction (/usr/local/lib/node_modules/firebase-tools/lib/emulator/functionsEmulatorRuntime.js:555:12)
    at /usr/local/lib/node_modules/firebase-tools/lib/emulator/functionsEmulatorRuntime.js:582:15
    at Generator.next (<anonymous>)
    at /usr/local/lib/node_modules/firebase-tools/lib/emulator/functionsEmulatorRuntime.js:8:71
    at new Promise (<anonymous>)
    at __awaiter (/usr/local/lib/node_modules/firebase-tools/lib/emulator/functionsEmulatorRuntime.js:4:12)
    at runHTTPS (/usr/local/lib/node_modules/firebase-tools/lib/emulator/functionsEmulatorRuntime.js:578:12)

Here's the code I'm using to make the Client object. I've made sure each variable is giving a valid string with the correct secrets and everything.

plaidClient = new plaid.Client({
            clientID: plaidClientId,
            secret: plaidSecret,
            env: plaid.environments.development,
            options: {
              version: '2019-05-29', 
            }
          })
@thecoolwinter
Copy link
Author

I've figured it out. In the /lib/PlaidClient.js the function params don't match what's in the example and getting started pages. Instead of passing an object, it takes four strings and an options object.

function Client(client_id, secret, public_key, env, options) {
    ...

I was getting this error because plaid was finding the secret param nil.

If someone could update the README it'd be useful for future people.

@gorbat-o
Copy link

gorbat-o commented Nov 16, 2020

What is supposed to be the public_key when we are not supposed to use it anymore?
It says link_token. Which I also don't understand why it is here, because we are supposed to use it to get the publicTokenExchange.
I am trying to create the link token with plaidClient.createLinkToken
image

My init looks like this:

const plaidClient = new plaid.Client({
    clientID: functions.config().plaid.clientid,
    secret: functions.config().plaid.secret,
    env: plaid.environments.development,
});

The Client init checks for these:

if (!R.is(Object, configs)) {
    throw new Error('Unexpected parameter type. ' +
    'Refer to https://github.com/plaid/plaid-node ' +
    'for how to create a Plaid client.');
  }

  if (R.isNil(configs.clientID)) {
    throw new Error('Missing Plaid "clientID"');
  }

  if (R.isNil(configs.secret)) {
    throw new Error('Missing Plaid "secret"');
  }

  if (!R.any(R.equals(configs.env), R.values(plaidEnvironments))) {
    throw new Error('Invalid Plaid environment');
  }

So it seems that it should be fine in my case, but it is not.

Edit: I changed it to not have an object anymore.

const plaid = require("plaid");
const plaidClient = new plaid.Client(functions.config().plaid.clientid,
functions.config().plaid.secret,
plaid.environments.dev,
);

Now it says invalide Plaid env

Edit 2: I changed plaid.environments.development to plaid.environments.dev.
Now it says that it is missing the public_key. Which is??? we are not supposed to use a public_key...

even here it says that I do the thing right 😅 https://plaid.com/docs/link/link-token-migration-guide/

@gorbat-o
Copy link

Alright, the solution is to actually use what the documentation says.
as of this:

const plaidClient = new plaid.Client({
    clientID: functions.config().plaid.clientid,
    secret: functions.config().plaid.secret,
    env: plaid.environments.development,
});

And to be sure you are using at least the version 7.0.0.
For some reason when adding a package with npm, it is installing the 2.1.0 which is absolutely not right.

@killerrings
Copy link

It's still fetching me some error and I'm not being able to find a way around it.
image

@sarthak-arora1997
Copy link

i am getting the exact same error, any form of help would be really appreciated, very close to my deadline for this one, please help !!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants