Plaid webhook 必须是非空字符串 URL

Plaid webhook must be a non-empty string URL

我正在使用 plaid-python 库调用 https://plaid.com/docs/api/tokens/#linktokencreate 端点。当我创建一个 link 令牌请求时。

LinkTokenCreateRequest:

{'client_name': 'MYCLIENTNAME', 'country_codes': ['US'], 'language': 'en', 'products': ['auth', 'transactions'], 'user': {'client_user_id': 'XXXXXXXXXX'}, 'webhook': '/webhooks/091e07ab'}

格子响应是:

{
"display_message": null,
"documentation_url": "https://plaid.com/docs/#create-link-token",
"error_code": "INVALID_FIELD",
"error_message": "webhook must be a non-empty string URL",
"error_type": "INVALID_REQUEST",
"request_id": "E************p",
"suggested_action": null
}

如果我省略 webhook 参数,该请求将有效。这是代码:

webhook_url = f"/webhooks/{user_hook_id}"
logger.info(f"webhook_url = {webhook_url}")
api_client = create_plaid_client()
client = plaid_api.PlaidApi(api_client)
token_request = LinkTokenCreateRequest( 
    products=[Products('auth'), Products('transactions')],
    webhook=webhook_url,
    client_name=client_name,
            country_codes=[CountryCode('US')],
            language='en',
            user=LinkTokenCreateRequestUser(
                client_user_id=user_hook_id
            )
        )
        logger.info(f"token_request = {token_request}")
        # create link token
        token_response = client.link_token_create(token_request)
        token = token_response['link_token']

我也试过使用完整的主机名和 uri,但都产生相同的错误。请求有什么问题?

更新 1:

我 运行 再次测试,这是输出。这次我注意到 token_request 中的 webhook 的一件事是它看起来格式不正确。我这样调用 LinkTokenCreateRequest:

token_request = LinkTokenCreateRequest( 
    products=[Products('auth'), Products('transactions')],
    webhook=webhook_url,
    client_name=client_name,
            country_codes=[CountryCode('US')],
            language='en',
            user=LinkTokenCreateRequestUser(
                client_user_id=user_hook_id
            )
        )

调用的输出如下。您可以看到使用空字符串生成了 webhook,然后是我提供的 webhook。

[INFO]  2021-11-03T22:52:36.263Z    ba0ad99b-76bd-42bf-b096-ca3e75b764dc    webhook_url =  https://b4234etcA3.execute-api.us-east-1.amazonaws.com/dev/webhooks/64a0f8d03754
[INFO]  2021-11-03T22:52:36.429Z    ba0ad99b-76bd-42bf-b096-ca3e75b764dc    token_request = {'client_name': 'Test',
 'country_codes': ['US'],
 'language': 'en',
 'products': ['auth', 'transactions'],
 'user': {'client_user_id': '64a0f8d03754'},
 'webhook': ' '
            'https://b4234etcA3.execute-api.us-east-1.amazonaws.com/dev/webhooks/64a0f8d03754'}

2021-11-03T15:52:36.816-07:00            [ERROR] ApiException: (400)
            Reason: Bad Request
            HTTP response headers: HTTPHeaderDict({'Server': 'nginx', 'Date': 'Wed, 03 Nov 2021 22:52:36 GMT', 'Content-Type': 'application/json; charset=utf-8', 'Content-Length': '289', 'Connection': 'keep-alive', 'plaid-version': '2020-09-14'})
            HTTP response body: {
                "display_message": null,
                "documentation_url": "https://plaid.com/docs/#create-link-token",
                "error_code": "INVALID_FIELD",
                "error_message": "webhook must be a non-empty string URL",
                "error_type": "INVALID_REQUEST",
                "request_id": "FrPnbQEDoQgI4f6",
                "suggested_action": null
            }

webhook 参数需要在请求中包含整个 webhook 端点 URI,包括 https:// 部分。