AWS Cognito adminCreateUser 可以发送临时密码吗?

Can AWS Cognito adminCreateUser send a temporary password?

临时密码上的 Amazon Cognito adminCreateUser documentation 指出:

This parameter is not required. If you do not specify a value, Amazon Cognito generates one for you.

用户是如何获得它的?起初我以为它会通过电子邮件发送给用户,但事实并非如此。然后我想也许它会在回应中回来。没有。

这是我在节点 JS Lambda 函数中调用的代码:

adminCreateUser(
{
    "UserPoolId": "us-east-1_XXXXXXXX",
    "Username": "roger__mailinator.com",
    "DesiredDeliveryMediums": [
        "EMAIL"
    ],
    "ForceAliasCreation": false,
    "MessageAction": "SUPPRESS",
    "UserAttributes": [
        {
            "Name": "given_name",
            "Value": "Rodger"
        },
        {
            "Name": "family_name",
            "Value": "Ribbit"
        },
        {
            "Name": "name",
            "Value": "Rodger Ribbit"
        },
        {
            "Name": "email",
            "Value": "roger@mailinator.com"
        },
        {
            "Name": "custom:title",
            "Value": "Animation Designer"
        },
        {
            "Name": "custom:company",
            "Value": "76"
        }
    ]
}, function(error, data) {
    if (error) {
      console.log("Error adding user to cognito: " + error, error.stack);
      //...
    } else {
      console.log("Received back from cognito: " + JSON.stringify(data));
      //...
    }
  });

这是我得到的回复:

Received back from cognito:
{
    "User": {
        "Username": "roger__mailinator.com",
        "Attributes": [
            {
                "Name": "custom:title",
                "Value": "Animation Designer"
            },
            {
                "Name": "sub",
                "Value": "1cd612a0-0da0-4e7b-84c7-30570fab80a9"
            },
            {
                "Name": "name",
                "Value": "Rodger Ribbit"
            },
            {
                "Name": "given_name",
                "Value": "Rodger"
            },
            {
                "Name": "family_name",
                "Value": "Ribbit"
            },
            {
                "Name": "email",
                "Value": "roger@mailinator.com"
            },
            {
                "Name": "custom:company",
                "Value": "76"
            }
        ],
        "UserCreateDate": "2017-03-30T18:31:34.283Z",
        "UserLastModifiedDate": "2017-03-30T18:31:34.283Z",
        "Enabled": true,
        "UserStatus": "FORCE_CHANGE_PASSWORD"
    }
}

密码去哪儿了?我们应该猜吗? :-)

我认为这是因为你超过了 "MessageAction": "SUPPRESS"。这将抑制电子邮件的发送。

临时密码通过电子邮件发送给用户,他需要在首次登录时重新设置密码。

答案是用户电子邮件需要在收到之前进行验证。所以需要修改email上的user属性进行验证。参见: