Python Lambda在确认后触发时给出botocore.errorfactory.InvalidLambdaResponseException
我设置了AWS Lambda函数,该函数在AWS Cognito上触发。成功发送电子邮件确认时的触发器。Lambda函数在Python3.6中 我指的是AWS文档中的Cognito后确认触发器。Python Lambda在确认后触发时给出botocore.errorfactory.InvalidLambdaResponseException,python,python-3.x,aws-lambda,amazon-cognito,Python,Python 3.x,Aws Lambda,Amazon Cognito,我设置了AWS Lambda函数,该函数在AWS Cognito上触发。成功发送电子邮件确认时的触发器。Lambda函数在Python3.6中 我指的是AWS文档中的Cognito后确认触发器。 “响应”:{} 到目前为止,我已尝试返回None、{}、{}(空json字符串)或有效字典,如{'status':200、'message':'themessagestring'},但它给出了错误 botocore.errorfactory.InvalidLambdaResponseException
“响应”:{}
到目前为止,我已尝试返回None、{}、{}(空json字符串)或有效字典,如{'status':200、'message':'themessagestring'},但它给出了错误
botocore.errorfactory.InvalidLambdaResponseException:调用ConfirmSignUp操作时发生错误(InvalidLambdaResponseException):无法识别的lambda输出
确认后功能的有效响应应该是什么?
下面是代码的一部分
from DBConnect import user
import json
def lambda_handler(event, context):
ua = event['request']['userAttributes']
print("create user ua = ", ua)
if ('name' in ua):
name = ua['name']
else:
name = "guest"
newUser = user.create(
name = name,
uid = ua['sub'],
owner = ua['sub'],
phoneNumber = ua['phone_number'],
email = ua['email']
)
print(newUser)
return '{}' # <--- I am using literals here only.
从数据库连接导入用户
导入json
def lambda_处理程序(事件、上下文):
ua=事件['request']['userAttributes']
打印(“创建用户ua=,ua”)
如果(ua中的“名称”):
name=ua['name']
其他:
name=“来宾”
newUser=user.create(
name=name,
uid=ua['sub'],
所有者=ua['sub'],
phoneNumber=ua[“电话号码”],
email=ua['email']
)
打印(新用户)
返回“{}”#您需要返回事件对象:
返回事件
这在文档中提供的示例中并不明显。您可能需要检查并确保事件对象确实包含响应键(它应该包含)。能否共享您的代码?是的,请共享生成响应的代码。请尝试返回“”,以下答案对我有效。显然,AWS Cognito需要一个作为参数传递给函数的整个事件对象。