注册用户时出现此错误:
调用SignUp操作时发生错误(InvalidLambdaResponseException):无法识别的lambda输出。
我的代码:
from __future__ import print_function
import json
import boto3
import botocore.exceptions
import hmac
import hashlib
import base64
import json
import uuid
client = None
USER_POOL_ID = 'us-east-2_ssqaX****';
CLIENT_ID = '40kq19dp3tgaost148115****';
CLIENT_SECRET = '1rbns01jnv2ckiu1so8ntqjt8l6r****lgq2a4hni642s*****';
ERROR = 0
SUCCESS = 1
USER_EXISTS = 2
def get_secret_hash(username):
msg = username + CLIENT_ID
dig = hmac.new(str(CLIENT_SECRET).encode('utf-8'),
msg = str(msg).encode('utf-8'), digestmod=hashlib.sha256).digest()
d2 = base64.b64encode(dig).decode()
print("here" + d2)
return d2
def lambda_handler(event, context):
global client
if client == None:
client = boto3.client('cognito-idp')
body = event
username = body['username']
password = body['password']
resp = client.sign_up(
ClientId=CLIENT_ID,
SecretHash=get_secret_hash(username),
Username=username,
Password=password
)
return {"resp": resp}
调用SignUp操作时发生错误(InvalidLambdaResponseException):无法识别的lambda输出:InvalidLambdaResponseException