首页 > 解决方案 > response-to-auth-challenge 返回错误:提供的会话无效

问题描述

夏天的

我将尝试为创建的用户设置新密码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-authand respond-to-auth-challenge,不是admin-xxx因为它应该被客户端应用程序调用。)

标签: amazon-cognito

解决方案


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

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

推荐阅读