respond-to-auth-challenge returns 错误:提供的会话无效

respond-to-auth-challenge returns erros: Invalid session provided

夏天

我将尝试为 admin-create-user 创建的用户设置新密码。

$ aws cognito-idp admin-create-user \
--user-pool-id ap-northeast-1_xxxxxxxx \
--username test@example.com \
--user-attributes \
  Name=email,Value=test@example.com \
  Name=email_verified,Value=True \
  Name=given_name,Value=hoge \
  Name=family_name,Value=fuga \
  Name=custom:hoge,Value=fuga

第一次登录时,需要NEW_PASSWORD_REQUIRED

$ aws cognito-idp initiate-auth \
--client-id client-id-xxxx \
--auth-flow USER_PASSWORD_AUTH \
--auth-parameters \
    USERNAME=test@example.com,PASSWORD=xxxxxxxx

{
    "ChallengeName": "NEW_PASSWORD_REQUIRED",
    "Session": "session"
    "ChallengeParameters": {
        "USER_ID_FOR_SRP": "session-xxxxx",
        "requiredAttributes": "[]",
        "userAttributes": "{\"email_verified\":\"True\",\"custom:department\":\"
    }
}

所以我打电话给 respond-to-auth-challenge 来解决 NEW_PASSWORD_REQUIRED 状态。
但是它返回了错误,即使我设置了 initiate-auth.

返回的相同会话
$ aws cognito-idp respond-to-auth-challenge \
--client-id client-id-xxxx \
--challenge-responses "NEW_PASSWORD=Password1234,USERNAME=test@example.com" \
--challenge-name NEW_PASSWORD_REQUIRED \
--session session-xxxxx

An error occurred (CodeMismatchException) when calling the RespondToAuthChallenge operation: Invalid session provided

我想知道如何解决这个错误。

(※ 我调用了 initiate-authrespond-to-auth-challenge,而不是 admin-xxx,因为它应该由客户端应用程序调用。)

很抱歉,这个问题已经解决了。
这仅仅是因为会话太长而我的终端没有显示完整的会话。
所以我将输出写入文件。

aws cognito-idp initiate-auth \
--client-id 3hnanmnckc1b7lejgs1m8supri \
--auth-flow USER_PASSWORD_AUTH \
--auth-parameters \
    USERNAME=sekiguchi@mmmcorp.co.jp,PASSWORD=wancZJiw6@ >> cognito_initiate-auth.txt