Skip to content

Instantly share code, notes, and snippets.

@franzwong
Created January 22, 2019 12:01
Show Gist options
  • Save franzwong/c01b53fefb7b4e1cda4adc57cca4f9f0 to your computer and use it in GitHub Desktop.
Save franzwong/c01b53fefb7b4e1cda4adc57cca4f9f0 to your computer and use it in GitHub Desktop.
HowTo: Implement user sign up and login with AWS Cognito
async function login(email, password) {
try {
const cognito = new AWS.CognitoIdentityServiceProvider()
return await cognito.adminInitiateAuth({
AuthFlow: 'ADMIN_NO_SRP_AUTH',
ClientId: process.env.CLIENT_ID,
UserPoolId: process.env.USER_POOL_ID,
AuthParameters: {
USERNAME: email,
PASSWORD: password
}
}).promise()
} catch (err) {
throw err
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment