Plaid 的 LinkTokenCreate 在 node.js 中给出 400 错误

wor*_*s98 6 javascript node.js plaid

还有其他人对 Plaid 的 linkTokenCreate 方法有疑问吗?我使用 node.js 作为后端,当我与前端一起运行它时,错误从涉及此函数的行开始。

即使我使用标准快速启动选项,我仍然收到相同的 400 bad request 错误。

这是后端代码,与快速入门相同。我只是测试链接令牌,因此它是我定义的唯一路由。

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);
});
Run Code Online (Sandbox Code Playgroud)

这是错误:

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)
Run Code Online (Sandbox Code Playgroud)

Emi*_*ily 4

可能很愚蠢 - 但当我收到这个确切的错误时,这是​​因为我们没有在格子仪表板中注册我们的 URI。

注册您的重定向 URI:

登录 Plaid Dashboard 并转至团队设置 -> API 页面。在“允许的重定向 URI”旁边,单击“配置”,然后单击“添加新 URI”。输入您的重定向 URI,您还必须将其设置为应用程序的通用链接,例如:https://app.example.com/plaid/。单击保存更改。