Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/opencv/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Swift 如何使用AWSMobileClient对Amazon Cognito进行身份验证?_Swift_Amazon Cognito_Aws Sdk Ios - Fatal编程技术网

Swift 如何使用AWSMobileClient对Amazon Cognito进行身份验证?

Swift 如何使用AWSMobileClient对Amazon Cognito进行身份验证?,swift,amazon-cognito,aws-sdk-ios,Swift,Amazon Cognito,Aws Sdk Ios,问题: 我在Cognito中有两个用户池。让我们将它们称为池A和池B。我能够成功地对用户进行“池A”的身份验证 我需要对后端创建的用户进行身份验证,以便从客户端动态地访问“池B” 我读过的文件: *亚马逊放大 *亚马逊干邑 *iOS版亚马逊SDK *不良客户 我的设置: *AWSMobileClient v2.9.8 我尝试了以下解决方案: awsconfiguration.json包含有关“池A”的信息 我登录用户以“池a”并执行业务逻辑(成功) 我全局注销用户并使令牌无效。(成功) 我从代

问题: 我在Cognito中有两个用户池。让我们将它们称为池A和池B。我能够成功地对用户进行“池A”的身份验证

我需要对后端创建的用户进行身份验证,以便从客户端动态地访问“池B”

我读过的文件: *亚马逊放大 *亚马逊干邑 *iOS版亚马逊SDK *不良客户

我的设置: *AWSMobileClient v2.9.8

我尝试了以下解决方案:

  • awsconfiguration.json包含有关“池A”的信息
  • 我登录用户以“池a”并执行业务逻辑(成功)
  • 我全局注销用户并使令牌无效。(成功)
  • 我从代码中设置了“池B”的配置,我不确定如何在awsconfiguration.json中指定多个用户池。不确定这是否可行
  • 我登录“池B”中后端创建的用户。(失败,错误消息为“无法登录用户”)
AWSMobileClient.sharedInstance().signIn( 用户名:“用户\u在\u池中\u存在”, 密码:“密码” ){结果,错误在

        debugPrint(result, error)

        // Async sign out

        AWSMobileClient.sharedInstance().signOut(
            options: .init(
                signOutGlobally: true,
                invalidateTokens: true
            ),
            completionHandler: { error in

            debugPrint(error)

            // setup configuration for "Pool B"
            let serviceConfig = AWSServiceConfiguration(
                region: .USWest2,
                credentialsProvider: nil
            )

            let poolConfig = AWSCognitoIdentityUserPoolConfiguration(
                clientId: "pool_b_client_id", clientSecret: nil, poolId: "pool_b_id"
            )

            // init pool client
            AWSCognitoIdentityUserPool.register(
                with: serviceConfig,
                userPoolConfiguration: poolConfig,
                forKey: "some_key"
            )

            AWSMobileClient.sharedInstance().signIn(
                username: "user_present_in_pool_b",
                password: "password"
            ) { result, error in
                debugPrint(result, error)
            }
        })
    }
AWSMobileClient.Error(“无法让最终用户登录”)