title: AWS Cognito check and get users
body: <p>I'm building an iOS App that is using Amazon MobileHub. Currently it's associated with Cognito and the sign up and sign in flow works great.</p>
  
  <p>What I'm trying to achieve is for one user to be able to add another user as a <em>friend</em> so to speak. To make that possible, I need to check if a user with a specific username exists and if it does, get some attributes such as the name of that target user.</p>
  
  <p>I've tried to use the get user > get details function but it gives me an error <strong>Authentication delegate not set</strong>.</p>
  
  <p>Here's the code I used:</p>
  
  <pre><code>var pool: AWSCognitoIdentityUserPool?
  let user = pool?.getUser(usernameField.text!)
  
  self.pool = AWSCognitoIdentityUserPool.init(forKey: AWSCognitoUserPoolsSignInProviderKey)
  
  user?.getDetails().continueWith { (task: AWSTask&lt;AWSCognitoIdentityUserGetDetailsResponse&gt;) -&gt; Any? in
    if let error = task.error as NSError? {
      print("ERROR: " + error.localizedDescription)
      return ""
    }
  
    print(task.result)
    return ""
  }
  </code></pre>
  
  <p>An approach I thought of was to store the username and the attributes I want to access to DynamoDB and then access it there but that will just create double unnecessary entries.</p>