小编use*_*347的帖子

未为此客户端启用AWS Cognito身份验证USER_PASSWORD_AUTH流

我有一个带用户池的移动应用程序(用户名和密码).该应用程序适用于aws-amplify sdk.但是,想把代码移到Lambdas.所以,我使用Boto3编写了以下Lambda.

这是Lambda:

import boto3

def lambda_handler(event, context):
    client = boto3.client('cognito-idp')
    response = client.initiate_auth(
        ClientId='xxxxxxxxxxxxxx',
        AuthFlow='USER_PASSWORD_AUTH',
        AuthParameters={
            'USERNAME': 'xxxxxx',
            'PASSWORD': 'xxxxxx'
        }
    )
    return response
Run Code Online (Sandbox Code Playgroud)

尝试了admin_initiate_auth.

import boto3
def lambda_handler(event, context):
    client = boto3.client('cognito-idp')
    response = client.initiate_auth(
        UserPoolId='xxxxxxxxx',
        ClientId='xxxxxxxxxxxxxx',
        AuthFlow='USER_PASSWORD_AUTH',
        AuthParameters={
            'USERNAME': 'xxxxxx',
            'PASSWORD': 'xxxxxx'
        }
    )
    return response
Run Code Online (Sandbox Code Playgroud)

这是我得到的错误.

调用InitiateAuth操作时发生错误(InvalidParameterException):此客户端未启用USER_PASSWORD_AUTH流:InvalidParameterException Traceback(最近一次调用最后一次):
文件"/var/task/lambda_function.py",第12行,在lambda_handler'PASSWORD'中: 'xxxxx'文件"/var/runtime/botocore/client.py",第317行,在_api_call中返回self._make_api_call(operation_name,kwargs)文件"/var/runtime/botocore/client.py",第615行,在_make_api_call中raise error_class(parsed_response,operation_name)InvalidParameterException:调用InitiateAuth操作时发生错误(InvalidParameterException):此客户端未启用USER_PASSWORD_AUTH流

有什么想法吗?

python amazon-web-services boto3 aws-cognito

10
推荐指数
2
解决办法
7577
查看次数

标签 统计

amazon-web-services ×1

aws-cognito ×1

boto3 ×1

python ×1