我创建了一个IBM Cloudant数据库,并尝试通过基于传统HTTP Cookie的身份验证进行连接,但失败,并显示401代码。
为什么失败,因为我正确地遵循了每个步骤?
请求:
url:
'https://<username>.cloudant.com/_session',
method: 'POST',
json: true,
body:
{ name: '<username>',
password: '<apiKey>' },
响应:401未经授权
{
"error": "unauthorized",
"reason": "Name or password is incorrect."
}
Ref:
https://cloud.ibm.com/docs/Cloudant?topic=Cloudant-authentication#cookie-authentication
通常,如果使用IBM Cloud IAM,需要提供用户名/密码,则可以使用“ apikey”作为用户名,并使用实际的API密钥作为密码。或者,如果您的凭据同时包含API密钥和密码,则您将传递用户名和所包含的密码。
使用用户名和API密钥作为密码会导致错误。