不断得到Authentication+failed.+API+credentials+are+incorrect
Posted
技术标签:
【中文标题】不断得到Authentication+failed.+API+credentials+are+incorrect【英文标题】:Constantly get Authentication+failed.+API+credentials+are+incorrect 【发布时间】:2012-07-17 21:00:00 【问题描述】:我正在尝试创建简单的 PayPal Pay API 操作,当我从控制台运行此代码时,它给了我响应,即创建了付款。
现在,当我试图从我的控制器运行它时,它给了我
Authentication+failed.+API+credentials+are+incorrect.
这是我的控制器:
def pay
require 'httpclient'
require 'xmlsimple'
clnt = HTTPClient.new
credentials =
'USER' => 'payer_1342623102_biz_api1.gmail.com',
'PWD' => '1342623141',
'SIGNATURE' => 'Ay2zwWYEoiRoHTTVv365EK8U1lNzAESedJw09MPnj0SEIENMKd6jvnKL '
header = "X-PAYPAL-SECURITY-USERID" => "payer_1342623102_biz_api1.gmail.com",
"X-PAYPAL-SECURITY-PASSWORD" => "1342623141",
"X-PAYPAL-SECURITY-SIGNATURE" => "Ay2zwWYEoiRoHTTVv365EK8U1lNzAESedJw09MPnj0SEIENMKd6jvnKL ",
"X-PAYPAL-REQUEST-DATA-FORMAT" => "NV",
"X-PAYPAL-RESPONSE-DATA-FORMAT" => "XML",
"X-PAYPAL-APPLICATION-ID" => "APP-80W284485P519543T"
data = "actionType" => "PAY",
"receiverList.receiver(0).email"=> "denmed_1342605975_biz@gmail.com",
"receiverList.receiver(0).amount" => "10",
"currencyCode" => "USD",
"cancelUrl" => "http://127.0.0.1:3000",
"returnUrl" => "http://127.0.0.1:3000",
"requestEnvelope.errorLanguage" => "en_US"
uri = "https://svcs.sandbox.paypal.com/AdaptivePayments/Pay"
res = clnt.post(uri, data, header)
@xml = XmlSimple.xml_in(res.content)
payKey = @xml["payKey"].to_s()
payKey = payKey.tr("[]", "")
payKey = payKey[1..20]
redirect_to "https://svcs.sandbox.paypal.com/AdaptivePayments/Pay?cmd=_ap-payment&paykey=#payKey"
end
一切都好吗?谁能提出我的请求失败的原因?
【问题讨论】:
【参考方案1】:一位好人发现了我的错误。我将用户重定向到错误的网址。
这一行:
redirect_to "https://svcs.sandbox.paypal.com/AdaptivePayments/Pay?cmd=_ap-payment&paykey=#payKey"
应该是:
redirect_to "https://sandbox.paypal.com/webscr?cmd=_ap-payment&paykey=#paykey"
【讨论】:
【参考方案2】:我遇到了同样的错误:我意识到我忘了包含
sandbox_email_address: xxx@example.com
在我的 yml 文件中
【讨论】:
以上是关于不断得到Authentication+failed.+API+credentials+are+incorrect的主要内容,如果未能解决你的问题,请参考以下文章
YAPI内网部署问题:MongoNetworkError: Authentication failed., mongodb Authentication failed
如何解决“令牌检索失败:AUTHENTICATION_FAILED”?
sourcetree Authentication failed
mongoexport遭遇Authentication failed
on namespace ceilometer.$cmd failed: Authentication failed. 问题处理方案