【发布时间】:2020-05-08 22:26:22
【问题描述】:
我想使用 HTTP 基本身份验证来密码保护可编程短信的状态回调端点。在没有授权标头的 Twilio 的初始请求中,我发回了状态代码 401,其中 WWW-Authenticate 标头设置为“基本领域='某个领域'”。但是,我没有收到来自 Twilio 的带有授权标头的以下请求。
参考:https://www.twilio.com/docs/usage/security#http-authentication
// 发送带有状态回调的短信
const details = await client.messages
.create({
body: 'This is the ship that made the Kessel Run in fourteen parsecs?',
from: 'TEST',
to: '......',
statusCallback: `https://user123:pass123@foo.com/status`
})
// 来自日志的 Lambda 响应标头
Method response headers: {WWW-Authenticate=Basic realm='Validate twilio request', Content-Type=application/xml}
注意:为什么需要基本身份验证的原因是使用提供的用户名和密码来验证请求的真实性。我没有使用 X-Twilio-Signature HTTP 标头,因为我无权访问身份验证令牌来验证请求并且正在使用 api 密钥发出请求。
【问题讨论】:
标签: twilio basic-authentication twilio-api http-authentication