title: Authorization code grant in lambda AWS with Serverless Framework
body: <p>I'm developing a lambda service with Serverless Framework that is responsible for logging into Cognito. </p>
  
  <pre><code>const aws_cognito = require('amazon-cognito-identity-js');
  
  const authDetails = new aws_cognito.AuthenticationDetails({
      Username: usuario,
      Password: password
  });
  
  const poolData = {
      UserPoolId: XXXXXXXX,
      ClientId: XXXXXXX
  };
  
  const userPool = new aws_cognito.CognitoUserPool(poolData);
  
  const userData = {
      Username: usuario,
      Pool: userPool
  };
  
  const cognitoUser = new aws_cognito.CognitoUser(userData);
  
  cognitoUser.authenticateUser(authDetails, {
      onSuccess: () =&gt; {
          console.log('OK');
      },
      onFailure: (err) =&gt; {
          console.log(err);
      }
  });
  </code></pre>
  
  <p>For business reasons I need to simulate the UI that Cognito generates. The system should support OAUTH flows: "Authorization code grant" and "Implicit grant".</p>
  
  <p>"Implicit grant" works without problems, but I can not obtain the authorization code for "Authorization code grant".
  Is there any way to obtain the authorization code with the AWS SDK?</p>
  
  <p>Thanks!</p>