无法在开发模式下启动 Plaid quickstart 应用程序

Can't start Plaid quickstart app in development mode

我刚开始使用 Plaid。我已经在本地设置了快速启动应用程序,它在沙盒模式下运行良好。 Link 面板加载正常,我可以使用沙盒凭据登录机构。

我的 .env 文件如下所示:

PLAID_CLIENT_ID=xxxxxxxx
PLAID_SECRET=xxxxxxxx
PLAID_ENV=sandbox
PLAID_PRODUCTS=transactions
PLAID_COUNTRY_CODES=US,CA
PLAID_REDIRECT_URI=http://localhost:3000

我现在想检查 Plaid 是否可以与一些特定的 real/live 机构一起使用,因此我正在尝试更新我的快速启动应用程序以在开发模式下工作。为此,我只是将 PLAID_SECRET 更新为我的开发密钥,并将 PLAID_ENV 更新为 'development'.

当我现在启动应用程序时,起始页不再显示 'Launch Link' 按钮,而是显示:

日志表明问题出在 POST /api/create_link_token 调用上。如果我从该路由函数中删除错误处理,日志会显示问题:

Traceback (most recent call last):
  File "/Users/william/Personal/quickstart/python/venv/lib/python3.8/site-packages/flask/app.py", line 2447, in wsgi_app
    response = self.full_dispatch_request()
  File "/Users/william/Personal/quickstart/python/venv/lib/python3.8/site-packages/flask/app.py", line 1952, in full_dispatch_request
    rv = self.handle_user_exception(e)
  File "/Users/william/Personal/quickstart/python/venv/lib/python3.8/site-packages/flask/app.py", line 1821, in handle_user_exception
    reraise(exc_type, exc_value, tb)
  File "/Users/william/Personal/quickstart/python/venv/lib/python3.8/site-packages/flask/_compat.py", line 39, in reraise
    raise value
  File "/Users/william/Personal/quickstart/python/venv/lib/python3.8/site-packages/flask/app.py", line 1950, in full_dispatch_request
    rv = self.dispatch_request()
  File "/Users/william/Personal/quickstart/python/venv/lib/python3.8/site-packages/flask/app.py", line 1936, in dispatch_request
    return self.view_functions[rule.endpoint](**req.view_args)
  File "server.py", line 196, in create_link_token
    response = client.link_token_create(request)
  File "/Users/william/Personal/quickstart/python/venv/lib/python3.8/site-packages/plaid/api_client.py", line 769, in __call__
    return self.callable(self, *args, **kwargs)
  File "/Users/william/Personal/quickstart/python/venv/lib/python3.8/site-packages/plaid/api/plaid_api.py", line 5566, in __link_token_create
    return self.call_with_http_info(**kwargs)
  File "/Users/william/Personal/quickstart/python/venv/lib/python3.8/site-packages/plaid/api_client.py", line 831, in call_with_http_info
    return self.api_client.call_api(
  File "/Users/william/Personal/quickstart/python/venv/lib/python3.8/site-packages/plaid/api_client.py", line 406, in call_api
    return self.__call_api(resource_path, method,
  File "/Users/william/Personal/quickstart/python/venv/lib/python3.8/site-packages/plaid/api_client.py", line 200, in __call_api
    raise e
  File "/Users/william/Personal/quickstart/python/venv/lib/python3.8/site-packages/plaid/api_client.py", line 193, in __call_api
    response_data = self.request(
  File "/Users/william/Personal/quickstart/python/venv/lib/python3.8/site-packages/plaid/api_client.py", line 452, in request
    return self.rest_client.POST(url,
  File "/Users/william/Personal/quickstart/python/venv/lib/python3.8/site-packages/plaid/rest.py", line 264, in POST
    return self.request("POST", url,
  File "/Users/william/Personal/quickstart/python/venv/lib/python3.8/site-packages/plaid/rest.py", line 223, in request
    raise ApiException(http_resp=r)
plaid.exceptions.ApiException: (400)
Reason: Bad Request
HTTP response headers: HTTPHeaderDict({'Server': 'nginx', 'Date': 'Sun, 16 May 2021 18:22:05 GMT', 'Content-Type': 'application/json; charset=utf-8', 'Content-Length': '301', 'Connection': 'keep-alive'})
HTTP response body: {
  "display_message": null,
  "documentation_url": "https://plaid.com/docs/?ref=error#invalid-input-errors",
  "error_code": "INVALID_API_KEYS",
  "error_message": "invalid client_id or secret provided",
  "error_type": "INVALID_INPUT",
  "request_id": "EbCTgZkFdeYQQ8r",
  "suggested_action": null
}

所以这表明我使用了错误的客户端 ID 或密码,但我不明白。客户端 ID 应该没问题(它在沙盒模式下工作),秘密绝对是我开发模式的秘密(我什至尝试生成一个新的但没有区别)。我错过了什么吗?

最后,如果我使用 Postman 到 POST 到 https://development.plaid.com/link/token/create 创建一个 link 令牌,使用相同的客户端 ID 和 'development' 秘密,它似乎可以工作很好(即我收到 200 响应和全新的 link 令牌)。

非常感谢任何帮助!

哎呀,好吧,这样就可以了:

https://github.com/plaid/quickstart/blob/master/python/server.py#L84

python Quickstart 似乎被硬编码为忽略 .env 文件中设置的环境变量。我们会解决的。同时,更改该行应该可以解决您的问题。

这是因为 Python 被硬编码到 Sandbox。这正在修复,同时,在 server.py 的第 84 行,您可以将其更改为:

"主机=plaid.Environment.Development"