我在这方面有点新意。我有一个基于反应的网络应用程序,我们一直在使用 AWS cognito 进行身份验证。我amazon-cognito-identity-js
用来在用户池中注册用户并进行登录。
现在我正试图用它替换那个库,aws amplify auth
因为它的界面很干净。但我不想经历设置过程(放大初始化和所有内容),我想像以前一样使用它amazon-cognito-identity-js
。
这是我到目前为止所做的,
我已经Amplify Auth
在我的app.js
文件中配置了 -
import Amplify from 'aws-amplify';
Amplify.configure({
Auth: {
// REQUIRED only for Federated Authentication - Amazon Cognito Identity Pool ID
identityPoolId: 'my id pool',
// REQUIRED - Amazon Cognito Region
region: 'my-region',
// OPTIONAL - Amazon Cognito User Pool ID
userPoolId: 'my-userpool',
// OPTIONAL - Amazon Cognito Web Client ID (26-char alphanumeric string)
userPoolWebClientId: 'my app client',
// OPTIONAL - Enforce user authentication prior to accessing AWS resources or not
mandatorySignIn: true,
// OPTIONAL - Manually set the authentication flow type. Default is 'USER_SRP_AUTH'
authenticationFlowType: 'USER_SRP_AUTH'
}
});
这是我在我的Registration
组件中注册所做的 -
const { username, password, email, name } = this.state;
try {
const result = await Auth.signUp({
username,
password,
attributes: {
'name': name,
'email': email,
'phone_number': '',
},
});
this.setState({showVerificationCode: true});
} catch(e) {
console.log(e);
}
现在,当我尝试在我的用户池中注册用户时,会创建用户并发送验证邮件。但是在客户端我收到了这个错误-
谁能告诉我是否有可能我正在尝试什么?您是否认为我只能在客户端单独使用
Auth
ofaws amplify
而没有任何云或任何东西来仅用户注册和登录用户池?