VISA api:无法发布请求并出现此错误,“预期的输入凭据不存在”

问题描述 投票:0回答:2

我是 VISA 开发人员的新手,正在尝试向 https://sandbox.api.visa.com/cofds-web/v1/datainfo 发送请求,以检查信用卡是否有效。

Python代码:

cert = 'C:\\Users\\user\\visa_cert\\cert.pem'

ca_cert = 'C:\\Users\\user\\visa_cert\\ca_cert.cer'
key = 'C:\\Users\\user\\visa_cert\\my_key.pem'

user_id = 'your user id of your project'
password = 'your password of your project'
timeout = 10

cred_info = 'credit_info.json'

payload = json.loads('''{
  "requestHeader": {
    "requestMessageId": "6da6b8b024532a2e0eacb1af58581",
    "messageDateTime": "2019-02-35 05:25:12.327"
  },
  "requestData": {
    "pANs": [
      4072208010000000
    ],
    "group": "STANDARD"
  }
}
''')

try:
    response = requests.post(url,
                            verify = (ca_cert),
                            cert=(cert, key),
                            # headers = headers,
                            auth=(user_id, password),
                            json = payload,
                            timeout=timeout
    )
except Exception as e:
    print(e)

执行本身成功,但响应显示“Ecpectd 输入凭据不存在”

响应头和内容如下。

# response header:
{'Server': 'nginx', 'Date': 'Fri, 03 Jun 2022 13:52:17 GMT', 'Content-Type': 'application/json;charset=UTF-8', 'Content-Length': '130', 'Connection': 'keep-alive', 'X-SERVED-BY': 'c6795c5t4', 'X-CORRELATION-ID': '1654264337_872_241384137_c6795c5t4_VDP_WS', 'X-ERROR-ORIGIN': '9200', 'X-APP-STATUS': '400', 'X-Frame-Options':
'SAMEORIGIN', 'X-XSS-Protection': '0', 'X-Content-Type-Options': 'nosniff', 'Strict-Transport-Security': 'max-age=31536000;includeSubdomains', 'Cache-Control': 'no-cache, no-store, must-revalidate', 'Pragma': 'no-cache', 'Expires': '-1'}
 
# response content:
b'{"responseStatus":{"status":400,"code":"9125","severity":"ERROR","message":"Expected input credential was not present","info":""}}'

我按照此处的说明(https://developer.visa.com/pages/working-with-visa-apis/two-way-ssl#configuring_a_twoway_ssl_keystor...)生成CA证书,仔细检查了我的证书user_id 和密码正确并且双向 SSL 证书处于活动状态。

我用谷歌搜索了这个错误,但我仍然不确定如何解决这个问题。

谢谢你。 无源无线电

ssl post request credentials visa-api
2个回答
0
投票

所以这个 API 需要消息级加密,所以我一直在努力弄清楚如何使用 API 实现 MLE,如果您尝试使用启用了 MLE 的 Visa 开发者中心,您将收到错误消息,但是如果您运行启用 MLE 后它就可以工作了。

因此,如果您弄清楚如何在代码中实现 MLE,我将不胜感激,因为文档非常模糊。

https://developer.visa.com/pages/cryption_guide


0
投票

此错误不是 MLE 的结果。这是因为请求标头中缺少#keyId。您可以从仪表板 -> 项目名称 -> 凭据生成密钥 ID,然后向下滚动到加密和解密。单击生成 keyId。

获取密钥后,您必须添加一个“keyId”标头,其中包含生成的密钥的值。现在发送请求。

发送请求后,Visa 会尝试使用 keyId 验证 MLE。您现在必须收到类似“令牌验证失败”的错误

© www.soinside.com 2019 - 2024. All rights reserved.