PayPal 交易搜索 API:PERMISSION_DENIED,请求的操作没有权限 [英] PayPal Transaction Search API: PERMISSION_DENIED, No Permission for the requested operation

查看:68
本文介绍了PayPal 交易搜索 API:PERMISSION_DENIED,请求的操作没有权限的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在编写一个服务(在 .NET Core 3.1 和 Refit 中,如果重要的话),它从我的 PayPal 业务帐户中提取给定日期范围内的交易活动,以在管理仪表板上使用.目前我正在这里学习教程:

I'm writing a service (in .NET Core 3.1 and Refit if it matters) that pulls transaction activities from my PayPal business account for a given date range to use on an admin dashboard. Currently I'm following the tutorial here:

https://developer.paypal.com/docs/api/get-an-access-token-postman/

这里:

https://developer.paypal.com/docs/api/transaction-搜索/v1/

第一部分,我可以得到一个授权密钥就好了(使用curl或postman,curl下面

The first part, I can get an authorization key just fine (using curl or postman, curl below

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 和代码中),我得到一个错误

This gives me an auth token both in postman and my custom service just fine. Next, when I try to pull the transactions (both in Postman and in code), I get an error

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 中检查了我的应用程序的交易历史记录,所以我很迷茫.

The info link in the error starts talking about 3rd party permissions, which I'm not sure is applicable because it is my Business account. Anyone have any ideas? I checked transaction history on my app in PayPal, so I'm at a lost.

提前致谢

推荐答案

你需要范围 https://uri.paypal.com/services/reporting/search/read .. 如果不是在 oauth2 响应中,仔细检查您的 REST 应用程序的权限.

You need the scope https://uri.paypal.com/services/reporting/search/read .. if it's not there in the oauth2 response, double check your REST App's permissions.

现有访问令牌缓存 9 小时 - 因此,如果您已请求 API 令牌,然后只是将此权限添加到您的应用,则该权限的新范围可能需要长达 9 小时才能反映在下一个令牌的一代.

Existing access tokens are cached for 9 hours--so if you already requested an API token and then just added this permission to your app, it can take up to 9 hours for that permission's new scope to be reflected in the next token's generation.

为避免等待 9 小时,您可以使用以下命令终止现有的缓存令牌:

To avoid waiting 9 hours, you can terminate that existing cached token with:

curl -X POST https://api.sandbox.paypal.com/v1/oauth2/token/terminate 
     -d "token=REPLACE_WITH_YOUR_TOKEN"

然后,您下一次获取令牌的调用将获得一个新生成的令牌,包括刚刚添加到 REST 应用程序的新范围.

Then your next call to get a token will get a newly-generated one, including the new scope that was just added to the REST app.

这篇关于PayPal 交易搜索 API:PERMISSION_DENIED,请求的操作没有权限的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆