用于可编程短信状态回调URL的Twilio HTTP身份验证

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

我想使用HTTP基本身份验证来密码保护可编程短信的状态回调端点。在来自Twilio的最初请求中,该请求没有Authorization标头,我发回了状态代码401,并将WWW-Authenticate标头设置为“ Basic realm ='some realm'”。但是,我没有从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:[email protected]/status`
   })

//日志中的Lambda响应标头

Method response headers: {WWW-Authenticate=Basic realm='Validate twilio request', Content-Type=application/xml}

注意:之所以需要基本身份验证,是为了使用提供的用户名和密码来验证请求的真实性。我没有使用X-Twilio-Signature HTTP标头,因为我无权访问auth令牌来验证请求,并且正在使用api键进行请求。

twilio basic-authentication twilio-api http-authentication
1个回答
0
投票

我在配置了Twilio statusCallback基本身份验证的Ngrok(启用身份验证)下进行了测试,并且可以正常工作。尝试修改您的响应标题,以查看是否有任何变化。

Ngrok返回以下响应头:

HTTP/1.1 401 Unauthorized
Content-Length: 20
Content-Type: text/plain
Www-Authenticate: Basic realm="ngrok"
© www.soinside.com 2019 - 2024. All rights reserved.