通常,人们会从先前的函数中获取一个 CognitoUser 对象。但是,我目前正在尝试只实现一个登录功能,因此不需要会返回 CognitoUser 的注册功能。如何创建 CognitoUser 以便我可以对登录进行身份验证?或者是否有更好的方法来验证登录?
CognitoUser 的构造函数受到保护。
最佳答案
我在发布它时就想通了。
您可以通过在初始化的 UserPool 上调用 getUser() 来创建一个空的 CognitoUser。
具体代码(不包括初始化和明显的样板代码):
user = userPool.getUser();
AuthenticationDetails authenticationDetails = new AuthenticationDetails(email, password, null);
user.authenticateUserInBackground(authenticationDetails, authenticationHandler);
关于android - 如何在不注册的情况下在 Android 中创建 CognitoUser?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42132401/