我无法让 Cognito 的 adminUpdateUserAttributes 工作。cli 可以工作,我可以让用户添加/更改不需要但希望看到它工作的用户。
我在 lambda 函数上使用 AmazonCognitoPowerUser 一个 AWS 托管策略,并且 lambda 正在触发,是否有我遗漏的东西,这听起来很简单,但它不起作用。
还有一种方法可以在不创建自己的情况下获得默认的创建日期。
const AWS = require('aws-sdk');
const cognitoidentityserviceprovider = new AWS.CognitoIdentityServiceProvider();
exports.handler = async (event) => {
cognitoidentityserviceprovider.adminUpdateUserAttributes(
{
UserAttributes: [
{
Name: 'custom:Date_Created',
Value: new Date().toString()
}
....
],
UserPoolId: " the correctpool id",
Username: "dagTest"
},
function(err, data) {
if (err) console.log(err, err.stack); // an error occurred
else console.log(data);
}
)};
// no errors and returns nothing as it says it should.
Run Code Online (Sandbox Code Playgroud)