Я пытаюсь пройти аутентификацию с помощью пакета amazon-cognito-vuex-module
https://github.com/Botre/amazon-cognito-vuex-module
Ниже приведен мой код для конфигурации Cognito:
export default new Vuex.Store({
modules: {
auth,
cognito: new AmazonCognitoVuexModule({
region: 'us-east-1',
userPoolId: '<myPoolId>',
clientId: '<myClientId>'
})
},
strict: debug
})
и этоВот как я пытаюсь аутентифицировать пользователя:
this.$store.dispatch('authenticateUser', { email: this.input.username, password: this.input.password })
authenticateUser Функция выглядит следующим образом:
authenticateUser ({ commit, state }, payload) {
return new Promise((resolve, reject) => {
commit('setAuthenticating', true)
const email = payload.email
const password = payload.password
const user = new CognitoUser({
Username: email,
Pool: state.pool
})
user.authenticateUser(
new AuthenticationDetails({
Username: email,
Password: password
}),
{
onFailure: function (error) {
commit('setAuthenticating', false)
reject(error)
},
onSuccess: function (session) {
commit('setAuthenticating', false)
commit('setAuthenticated', user)
resolve(session)
},
newPasswordRequired: function (userAttributes, requiredAttributes) {
commit('setAuthenticating', false)
delete userAttributes.email_verified // Immutable field
user.completeNewPasswordChallenge(
payload.newPassword,
userAttributes,
this
)
}
}
)
})
}
Получение следующей ошибки в ответе:
{"__ type": "NotAuthorizedException", "message": "Пользователь не авторизован для получения данных аутентификации."}