【发布时间】:2020-07-05 13:58:31
【问题描述】:
我正在编写一个服务(在 .NET Core 3.1 和 Refit 中,如果重要的话),它从我的 PayPal 业务帐户中提取给定日期范围内的交易活动,以便在管理仪表板上使用。目前我正在这里学习教程:
https://developer.paypal.com/docs/api/get-an-access-token-postman/
这里:
https://developer.paypal.com/docs/api/transaction-search/v1/
第一部分,我可以得到一个授权密钥就好了(使用curl或postman,curl下面
curl --location --request POST 'https://api.paypal.com/v1/oauth2/token' \
--header 'Content-Type: application/x-www-form-urlencoded' \
--header 'Authorization: Basic <my client id>:<my secret>' \
--header 'Content-Type: application/x-www-form-urlencoded' \
// not sure what this is, postman specific maybe?
--header 'Cookie: tsrce=devdiscoverynodeweb; ts=vr%3D0cee9361171ac120001362adffec14c3%26vreXpYrS%3D1679730671%26vteXpYrS%3D1585061694%26vt%3D0cee9390171ac120001362adffec14c2' \
--data-urlencode 'grant_type=client_credentials'
这在邮递员和我的自定义服务中都为我提供了一个身份验证令牌。接下来,当我尝试提取交易时(在 Postman 和代码中),我得到一个错误
cUrl:
curl --location --request GET 'https://api.paypal.com/v1/reporting/transactions?start_date=2020-03-01T00:00:00Z&end_date=2020-03-31T23:59:59Z' \
--header 'Authorization: Bearer <my token>' \
// Postman???
--header 'Cookie: tsrce=devdiscoverynodeweb; ts=vr%3D0cee9361171ac120001362adffec14c3%26vreXpYrS%3D1679730671%26vteXpYrS%3D1585061694%26vt%3D0cee9390171ac120001362adffec14c2'
错误:
{
"localizedMessage": "No permission for the requested operation. ",
"suppressed": [],
"name": "PERMISSION_DENIED",
"message": "No permission for the requested operation. ",
"details": [
{
"field": null,
"value": null,
"location": null,
"issue": "No permission for the requested operation. "
}
],
"information_link": "https://developer.paypal.com/docs/classic/products/permissions/",
"debug_id": "7e315038e8073"
}
错误中的信息链接开始谈论第 3 方权限,我不确定这是否适用,因为它是我的企业帐户。谁有想法?我在 PayPal 中检查了我的应用程序的交易历史记录,所以我很迷茫。
提前致谢
【问题讨论】:
-
您的 oauth2 调用实际返回了什么?我相信您需要范围
https://uri.paypal.com/services/reporting/search/read.. 如果它不存在,请仔细检查您的 REST 应用程序设置是否为 LIVE(不是沙盒) -
感谢您的及时回复。这是范围参数
{ "scope": "https://uri.paypal.com/services/payments/initiatepayment openid https://uri.paypal.com/services/applications/webhooks", ... } -
@PrestonPHX 我能够通过删除和重新创建应用程序来修复它。更改设置对原始版本没有任何作用。您能否将您的回复创建为答案,以便我将其标记为答案?
标签: asp.net-core curl paypal postman