【发布时间】:2019-11-17 09:45:17
【问题描述】:
我在这方面有点新意。我有一个基于反应的网络应用程序,我们一直在使用 AWS cognito 进行身份验证。我使用amazon-cognito-identity-js 在用户池中注册用户并进行登录。
现在我正试图用aws amplify auth 替换那个库,因为它的界面很干净。但我不想完成设置过程(放大初始化和所有内容),我想像使用amazon-cognito-identity-js 一样使用它。
这是我到目前为止所做的,
我已经在我的app.js 文件中配置了Amplify Auth -
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);
}
现在,当我尝试在我的用户池中注册用户时,该用户已创建,并且验证邮件也已发送。但是在客户端我收到了这个错误 -
谁能告诉我是否有可能我正在尝试什么?你认为我只能在客户端单独使用aws amplify 的Auth 没有任何云或任何东西,只是用户注册和登录用户池?
【问题讨论】:
标签: reactjs amazon-web-services aws-amplify amplifyjs