title: AWS - nodejs SDK - CognitoIdentityServiceProvider.initiateAuth - CredentialsError: Missing credentials in config
body: <p>I'm trying to get authentication working through my API using AWS Cognito with a user pool. I have a user created through an AWS Cognito User Pool and I'm trying to log in with the user.</p>
  
  <p>The error I'm getting is <code>CredentialsError: Missing credentials in config</code>. Specifically it was telling me that I needed an <code>IdentityPoolId</code>. But I can't seem to find this <code>IdentityPoolId</code> in my AWS console. Where the heck do I get this from for my user pool? All I see is a Pool id and a Pool ARN.</p>
  
  <p><a href="https://i.stack.imgur.com/ebcIY.png" rel="noreferrer"><img src="https://i.stack.imgur.com/ebcIY.png" alt="enter image description here"></a></p>
  
  <p>Relevant source code:</p>
  
  <pre><code>var aws = require('aws-sdk');
  aws.config.update({
      region: 'us-east-1',
      credentials: new aws.CognitoIdentityCredentials({
          IdentityPoolId: '???'
      })
  });
  
  
  var authUser = function(params, callback)
  {
      if (!params || !params.Email || !params._password)
      {
          callback(new Error('Invalid parameters.'));
          return false;
      }
  
      var cognito = new aws.CognitoIdentityServiceProvider();
  
      var authParams = {
          AuthFlow: 'USER_SRP_AUTH', // not sure what this means...
          ClientId: conf.AWSConfig.ClientId,
          AuthParameters: {
              Username: params.Email,
              Password: params._password
          }
      };
  
      cognito.initiateAuth(authParams, function(err, data)
      {
          if (err)
          {
              console.log('Error details: ' + util.inspect(err));
              callback(err);
              return false;
          }
          callback(null, {success: true, data: data});
      });
  }
  </code></pre>
  
  <p>For the <code>authParams</code> object, I'm not sure what the <code>AuthFlow</code> should be. Looking at <a href="http://docs.aws.amazon.com/AWSJavaScriptSDK/latest/AWS/CognitoIdentityServiceProvider.html#initiateAuth-property" rel="noreferrer">http://docs.aws.amazon.com/AWSJavaScriptSDK/latest/AWS/CognitoIdentityServiceProvider.html#initiateAuth-property</a> it seemed like <code>USER_SRP_AUTH</code> was what I should likely be using.</p>
  
  <p><strong>Edit:</strong></p>
  
  <p>I believe I may have found where to get my <code>IdentityPoolId</code>. I viewed my <code>Federated Identities</code> section and added in the appropriate <code>User Pool</code> under the <code>Authentication Providers</code> section while editing the identity pool.</p>
  
  <p><a href="https://i.stack.imgur.com/4ukS6.png" rel="noreferrer"><img src="https://i.stack.imgur.com/4ukS6.png" alt="enter image description here"></a></p>
  
  <p>I associated the <code>Authentication Provider</code> for <code>Cognito</code> to my User Pool that I created by entering the <code>User Pool ID</code> and <code>App Client ID</code> for that user pool. Now with the same code using that <code>Identity pool ID</code> I'm getting the error <code>CredentialsError: Missing credentials in config</code>. It says <code>Unauthorized access is not supported for this identity pool</code>. OK... I'm trying to authorize the user... Do I need to create an Unauthenticated role so that users can authenticate when they're not authenticated? That seems silly if that's what I need to do.</p>
  
  <p><strong>Edit 2:</strong></p>
  
  <p>I should also note that I was able to log in and get an <code>AccessToken</code> as well as an <code>IdToken</code> and <code>RefreshToken</code> using the Javascript SDK (not nodejs). I did this without the need of an <code>IdentityPoolId</code>. The only things I needed were a <code>UserPoolId</code> and a <code>ClientId</code>.</p>
  
  <pre><code>var authenticateUser = function(onSuccessCallback)
  {
      var authData = {
          Username: getUserName(), // gets username from an html text field
          Password: getPassword()  // gets password from an html password field
      };
  
      var authDetails = new AWSCognito.CognitoIdentityServiceProvider.AuthenticationDetails(authData);
  
      var cognitoUser = getCognitoUser();
  
      cognitoUser.authenticateUser(authDetails,
      {
          onSuccess: function(result)
          {
              console.log('access token: ' + result.getAccessToken().getJwtToken());
              console.log('idToken: ' + result.idToken.jwtToken);
              console.log(result);
  
              if (onSuccessCallback &amp;&amp; typeof(onSuccessCallback) == 'function')
              {
                  onSuccessCallback(cognitoUser);
              }
          },
          onFailure: function(err)
          {
              // UserNotConfirmedException: User is not confirmed.
              console.log('authError');
              alert(err);
          }
      });
  }
  </code></pre>