使用以下基于 AWS Lambda 的应用程序客户端,我尝试列出 Cognito 用户池中的所有用户。
let AWS = require('aws-sdk')
const COGNITO_CLIENT = new AWS.CognitoIdentityServiceProvider()
COGNITO_CLIENT.listUsers({
UserPoolId: 'MyUserPoolId',
AttributesToGet: ['default_attribute', 'custom:my_attribute']
}, callback)
默认情况下查询所有属性时一切正常(AttributesToGet: []//或完全排除此字段
)。但是,当针对自定义属性时,会引发 InvalidParameterException。这是使用 Amazon SDK for Node.js。
但是允许定位默认属性:
AttributesToGet: ['email', 'name', /* other non-custom */]
请您参考如下方法:
请删除“AttributesToGet”并尝试。