title: Cognito auth flow fails with "Already found an entry for username Facebook_10155611263153532"
body: <p>The goal is to implement a social provider auth flow as described in <a href="http://docs.aws.amazon.com/cognito/latest/developerguide/getting-started.html" rel="noreferrer">User Pools App Integration and Federation</a>.</p>
  <p>One important thing that I want to satisfy, is to merge user pool accounts that have the same email address.</p>
  <p>I am accomplishing that by calling <a href="http://docs.aws.amazon.com/AWSJavaScriptSDK/latest/AWS/CognitoIdentityServiceProvider.html#adminLinkProviderForUser-property" rel="noreferrer">adminLinkProviderForUser</a> within the PreSignUp_ExternalProvider cognito lambda trigger.</p>
  <p>So with this, everything works. The new social provided user is being registered and linked with the already existing Cognito (user+pass) user.</p>
  <p>However, the authentication flow, from user's perspective doesn't complete. It fails at the last step where the callback uri (defined in cognito user pool) is being called:</p>
  <blockquote>
  <p>error: invalid_request</p>
  <p>error_description: Already found an entry for username Facebook_10155611263152353</p>
  </blockquote>
  <p>But then, if the user retries the social auth flow, everything works, and would get session tokens that represent the original Cognito User Pool user (the one that already had that email).</p>
  <p>Note that I'm testing the auth flow on an empty User Pool, zero user accounts.</p>