import Amplify, { Auth } from 'aws-amplify';
Amplify.configure({
Auth: {
// 配置具体的身份验证方法
region: 'your-region',
userPoolId: 'your-user-pool-id',
userPoolWebClientId: 'your-user-pool-web-client-id',
authenticationFlowType: 'USER_PASSWORD_AUTH' // 指定身份验证方法为用户名密码登录
}
});
async function signIn() {
try {
const user = await Auth.signIn('username', 'password');
console.log('登录成功', user);
} catch (error) {
console.log('登录失败', error);
}
}
signIn();
在使用身份验证方法时,确保使用的参数与所用的身份验证方法一致,以避免类似的错误。