title: How can i authenticate to my Identity/User Pool with Cognito Identity?
body: <p>I have been trying to solve this for a few days now but i can't figure out what the problem is.</p>
  
  <p>I have a user pool and an identity pool on AWS Cognito. I have run the sample code and used it to log in and register users with Facebook and Google+ successfully. After login i am able to authenticate using the token to use SNS or the Sync services.</p>
  
  <p>I have registered a user and got a token (after logging in) with Cognito Identity. However the next step is to use the token to authenticate into the identity pool. This is where i keep getting the error </p>
  
  <p>I have followed the instructions from <a href="http://docs.aws.amazon.com/cognito/latest/developerguide/amazon-cognito-integrating-user-pools-with-identity-pools.html" rel="nofollow">Integrating User Pools with Amazon Cognito Identity</a> and I get a token which I then try to pass it along with the pool id to the credentials provider.</p>
  
  <pre><code>  credentialsProvider.clear();
    credentialsProvider.withLogins(loginMap).refresh();
  </code></pre>
  
  <p>My code fails on refresh(). At this point credentialsProvider is a AWSBasicCognitoIdentityProvider and refresh() fails in the super.refresh() which calls getIdentityId() in the abstract parent class AWSAbstractCognitoIdentityProvider </p>
  
  <pre><code>@Override
  public String getIdentityId() {
      if (identityId == null) {
          GetIdRequest getIdRequest = new GetIdRequest()
                  .withAccountId(getAccountId())
                  .withIdentityPoolId(getIdentityPoolId())
                  .withLogins(loginsMap);
  
          appendUserAgent(getIdRequest, getUserAgent());
  
          GetIdResult getIdResult = cib.getId(getIdRequest);
  </code></pre>
  
  <p>No matter what values i put in the loginsMap, i get the error</p>
  
  <blockquote>
    <p>Invalid login token. Issuer doesn't match providerName</p>
  </blockquote>
  
  <p>at cid.getid(getIdRequest).</p>
  
  <p>Most of the code is available to download free if you create an app in the Mobile Hub and generate the code. You can then configure authentication providers - FB, Google , etc.</p>
  
  <p>What am I doing wrong ?</p>
  
  <p>Thanks.</p>
  
  <p><strong>Edit</strong> : Here are examples of what i have tried
  The token is always the object in the map. Below are the different keys</p>
  
  <ul>
  <li>"cognito-identity.amazonaws.com"</li>
  <li>the User Pool id - us-east-1_xxxxxxxxx</li>
  <li>the User Pool ARN - cognito-idp:us-east-1:xxxxxxxxxxxx:userpool/us-east-1_xxxxxxxxx</li>
  </ul>