AWS Cognito登录(Android) [英] AWS Cognito Sign-In (Android)

查看:304
本文介绍了AWS Cognito登录(Android)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试弄清楚如何使用AWS Cognito登录用户。 教程似乎全部从注册用户而不是不登录的角度来看,与用户打交道。我不希望用户经历注册过程;这将由我们的办公室用户在其他地方完成。我只是想在此应用程序中让他们输入现有的用户名和密码并登录。



我目前对事物的理解是Cognito用户池仅支持使用诸如Facebook或Google之类的身份验证提供程序登录,或者仅支持未经身份验证的登录,这使我无法确定是否使用用户名和密码(我在该流程中找不到任何地方可以提供)用户名和密码)。也有Cognito联合身份,似乎也有一半时间被称为Cognito用户池,它具有上述注册教程,但仅与现有用户签名无关。



我是否必须使用用户池的联合身份版本才能使用用户名和密码登录?如果不是,我该如何使用非联合用户池?如果是这样,我该如何进行登录而不是注册的流程?我试图抓住上述教程中看起来相关的部分,但是由于我已经追赶我的尾巴好几周了,我感到很沮丧,因为只有更多的层次依赖于其他事物,而依赖于其他事物

解决方案

这有点混乱了流程的工作方式。正如@Ionut Trestian解释的那样,我们需要从池中创建似乎是空白用户的用户,然后对该用户进行身份验证。 API有所改变,这是更新的方法。地区;
//如果使用awsconfiguration.json,则为
// CognitoUserPool userPool = new CognitoUserPool(context,AWSMobileClient.getInstance()。getConfiguration());

AuthenticationDetails authDetails = new AuthenticationDetails(username,password,null);

CognitoUser user = userPool.getUser();

//您可能想要对线程中的以下位进行处理应该在后台
user.initiateUserAuthentication(authDetails,authHandler,true).run();


中完成

I am trying to figure out how to sign in a User with AWS Cognito. The tutorials all seem to deal with Users from a standpoint of signing up Users, not signing them in. I do not want the users to go through a sign-up process; that will be done elsewhere, by our office users. I just want to have, in this app, a flow that has them enter their existing username and password and sign in.

My current understanding of things is that Cognito User Pools only supports either sign-in using an authentication provider like Facebook or Google, or non-authenticated sign-in, which I am having trouble determining if this uses a username and password or not (I couldn't find anywhere in that flow to supply a username and password, in any case). There is also Cognito Federated Identities, which also seems to be called Cognito User Pools half the time, which has the aforementioned signup tutorials, but nothing about just signing in an existing User.

Do I have to use the Federated Identities version of User Pools in order to be able to sign in with a username and password? If not, how do I do that with non-Federated User Pools? If so, how do I make a flow just for signing in, not signing up? I am trying to grab just the pieces that look relevant from the aforementioned tutorial, but I am getting frustrated as I have been chasing my tail on this for weeks now, with only more layers of stuff that relies on other stuff that relies on other stuff in sight.

解决方案

It's a bit confusing how the flow works. As @Ionut Trestian explains we need to create what seems to be a blank user from the pool and then authenticate that user. APIs have changed a bit, this are the updated methods.

   CognitoUserPool userPool = new CognitoUserPool(context, userPoolId, clientId, clientSecret, region;
//OR if using awsconfiguration.json
//    CognitoUserPool userPool = new CognitoUserPool(context, AWSMobileClient.getInstance().getConfiguration());

AuthenticationDetails authDetails = new AuthenticationDetails(username, password, null);

CognitoUser user = userPool.getUser();

//You might want do to the following bit inside a thread as it should be done in background
user.initiateUserAuthentication(authDetails, authHandler, true).run();

这篇关于AWS Cognito登录(Android)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆