title: AWS Cognito + Rails API: How to get a token from my API after an user confirms its account
body: <p>I'm building a simple API and decided to delegate the user handling to AWS Cognito.</p>
  <p>So far I have this flow:</p>
  <p>Sign up</p>
  <pre class="lang-rb prettyprint-override"><code>email, password = ... # from front end
  
  response = @client.sign_up(
    client_id: CLIENT_ID, 
    username: email, 
    password: password
  )
  
  head :no_content
  </code></pre>
  <p>Confirm account</p>
  <pre class="lang-rb prettyprint-override"><code>email, confirmation_code = ... # from front end
  
  @client.confirm_sign_up(
    client_id: CLIENT_ID, 
    username: email, 
    confirmation_code: confirmation_code
  )
  
  head :no_content
  </code></pre>
  <p>Sign in</p>
  <pre class="lang-rb prettyprint-override"><code>email, password = ... # from front end
  
  response = @client.initiate_auth(
    client_id: CLIENT_ID,
    auth_flow: 'USER_PASSWORD_AUTH', 
    auth_parameters: { USERNAME: email, PASSWORD: password }
  )
  
  render json: { access_token: response.authentication_result.access_token }
  </code></pre>
  <p>Ideally, I would like to send an <code>access_token</code> when the user confirms his account. Otherwise, my frontend will have to redirect my user to the sign in form and enter his email/password again.</p>
  <p>I can't make this sign in call transparent as this could happen from another browser or session. I can't either generate the token at the sign_up page because it returns an errors saying the user isn't confirmed yet.</p>
  <p>What logic am I missing here?</p>