Created
          January 22, 2019 12:01 
        
      - 
      
- 
        Save franzwong/c01b53fefb7b4e1cda4adc57cca4f9f0 to your computer and use it in GitHub Desktop. 
    HowTo: Implement user sign up and login with AWS Cognito
  
        
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
  | 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