首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >问答首页 >Paypal:客户端身份验证失败

Paypal:客户端身份验证失败
EN

Stack Overflow用户
提问于 2019-02-04 15:19:44
回答 5查看 12K关注 0票数 5

尝试让我的paypal REST api网站上线。它在沙盒模式下工作得很好,经过验证的传输。

当我将沙箱切换为实时客户端ID和密钥时,我收到以下错误

代码语言:javascript
运行
复制
{"error":"invalid_client","error_description":"Client Authentication failed"}   

我检查并确保我的代码应该上线。

代码语言:javascript
运行
复制
$apiContext = new \PayPal\Rest\ApiContext(
 new \PayPal\Auth\OAuthTokenCredential(
  PP_CLIENT_ID ,     // ClientID
  PP_CLIENT_SECRET      // ClientSecret
 )
);

// setting mode to live
// https://github.com/paypal/PayPal-PHP-SDK/wiki/Going-Live

$apiContext->setConfig([
 'mode' => 'live',
]);

通过wp_ajax运行此程序

任何帮助都将不胜感激!谢谢!

2019年2月5日:似乎其他人也遇到了这个问题:https://github.com/paypal/PayPal-PHP-SDK/issues/435

在StackOverflow上我也错过了同样的问题……这也没有答案。PayPal App works perfectly as Sandbox, Client Authentication failed on Live: list of steps to check?

EN

回答 5

Stack Overflow用户

发布于 2019-11-13 05:08:38

尝试将return new SandboxEnvironment($clientId, $clientSecret);更改为

PayPalClient.php类中的return new ProductionEnvironment($clientId, $clientSecret);

票数 10
EN

Stack Overflow用户

发布于 2020-04-18 05:06:09

按照沙盒API works的PayPal REST API文档,我在尝试生成REST API令牌时也遇到了类似的问题。生活应该是一样的。请确保您正在获取REST API凭证,而不是获取"NVP/SOAP API应用程序“的秘密。

点击此处:https://developer.paypal.com/developer/applications/

在顶部选择Sandbox或Live

单击REST API apps下的Create App,而不是NVP/SOAP API apps

这将为您提供一个客户端ID和Secret,它们看起来都像一个由大小写字母数字组成的字符串,长度约为40-50个字符。

使用这些凭据,运行curl命令来获取访问令牌,这样您就可以调用REST API,替换您的客户端id和密钥:

代码语言:javascript
运行
复制
curl -v POST https://api.sandbox.paypal.com/v1/oauth2/token \
  -H "Accept: application/json" \
  -H "Accept-Language: en_US" \
  -u "CLIENT_ID:SECRET" \
  -d "grant_type=client_credentials"

这将返回您的令牌:

代码语言:javascript
运行
复制
Sample response
{
    "scope": "https://uri.paypal.com/services/invoicing https://uri.paypal.com/services/disputes/read-buyer https://uri.paypal.com/services/payments/realtimepayment https://uri.paypal.com/services/disputes/update-seller https://uri.paypal.com/services/payments/payment/authcapture openid https://uri.paypal.com/services/disputes/read-seller https://uri.paypal.com/services/payments/refund https://api.paypal.com/v1/vault/credit-card https://api.paypal.com/v1/payments/.* https://uri.paypal.com/payments/payouts https://api.paypal.com/v1/vault/credit-card/.* https://uri.paypal.com/services/subscriptions https://uri.paypal.com/services/applications/webhooks",
    "access_token": "A21AAFEpH4PsADK7qSS7pSRsgzfENtu-Q1ysgEDVDESseMHBYXVJYE8ovjj68elIDy8nF26AwPhfXTIeWAZHSLIsQkSYz9ifg",
    "token_type": "Bearer",
    "app_id": "APP-80W284485P519543T",
    "expires_in": 31668,
    "nonce": "2020-04-03T15:35:36ZaYZlGvEkV4yVSz8g6bAKFoGSEzuy3CQcz3ljhibkOHg"
}

您通常不会将这些东西集成到您的应用程序中,而是只需做一次,然后将REST API令牌嵌入到您的应用程序中。

我知道这是在重复显而易见的事情,但我希望这能有所帮助。

请参阅此处的更多说明:https://developer.paypal.com/docs/platforms/get-started/#step-1-get-api-credentials

票数 3
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/54511617

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档