title: Authenticate user with Cognito user pool credentials
body: <p>How to authenticate user WITHOUT identity pool/IdentityPoolId, only with user pool credentials?
  <a href="https://github.com/aws/amazon-cognito-identity-js" rel="nofollow noreferrer">https://github.com/aws/amazon-cognito-identity-js</a></p>
  
  <p>Example 4 in link above works only for/with identity pool,
  when i call for example method</p>
  
  <pre><code>cognitoUser.changePassword('oldPassword', 'newPassword', function(err, result) {}
  </code></pre>
  
  <p>retrun me error from CognitoUser.js, string 602-604</p>
  
  <pre><code>if (!(this.signInUserSession != null &amp;&amp; this.signInUserSession.isValid())) {
        return callback(new Error('User is not authenticated'), null);
      }
  </code></pre>
  
  <p>But when i call </p>
  
  <pre><code>cognitoUser.getSession(function(err, session) {if (err) {
                  alert(err);
                  return;
              }
              console.log('session validity: ' + session.isValid());
  </code></pre>
  
  <p>It's give me session tokens.</p>
  
  <p>How i'm trying to authenticate user:</p>
  
  <pre><code>const logins = {};
  logins['cognito-idp.' + environment.region + '.amazonaws.com/' + environment.UserPoolId] = session.getIdToken().getJwtToken();
  // Add the User's Id Token to the Cognito credentials login map.
  AWS.config.credentials = new AWS.CognitoIdentityCredentials({
     Logins: logins
  });
  </code></pre>
  
  <p>That give me error</p>
  
  <pre><code>Argument of type '{ Logins: {}; }' is not assignable to parameter of type 'CognitoIdentityOptions'.
  </code></pre>
  
  <p>What i'm trying to achieve:</p>
  
  <p>1) How to understand that cognito userpool user authenticated without identity pool?</p>
  
  <p>2) How to authenticate user?</p>
  
  <p>3) Object CognitoUser have 2 propreties:</p>
  
  <ul>
  <li>Session</li>
  <li>signInUserSession</li>
  </ul>
  
  <p>What are they for?
  How to use them properly?</p>
  
  <p>P.S. When im using like this way, all works fine, but i need to achieve it without identity pool</p>
  
  <pre><code>const creds = new AWS.CognitoIdentityCredentials({
  IdentityPoolId: environment.IdentityPoolId, // your identity pool id here
  Logins: {
  // Change the key below according to the specific region your user pool is in.
  [`cognito-idp.${environment.region}.amazonaws.com/${environment.UserPoolId}`]: session.getIdToken().getJwtToken()}},
  {
   region: environment.region
  });
  AWS.config.credentials = creds;
  </code></pre>