title: AWS Amplify currentAuthenticatedUser is null after FB Login in React Native, but when app is reloaded, currentAuthenticatedUser returns valid user
body: <p>I am trying to integrate Facebook login into my React Native app. </p>
  
  <p>I have been able to implement successfully the Auth.signIn() method, and I can consistently retrieve the user using Auth.currentAuthenticatedUser().</p>
  
  <p>However, when I use Auth.currentAuthenticatedUser() after getting the code from the Facebook login, it returns null.</p>
  
  <p>What's more, when I reload the app, Auth.currentAuthenticatedUser() returns the user as expected.</p>
  
  <p>I don't understand why, after I create a user session with the tokens, it does not recognize that I have an authenticated user.</p>
  
  <p>Here is my code:</p>
  
  <pre><code>getTokenbyCode = async (code) =&gt; {
        const details = {
          grant_type: 'authorization_code',
          code,
          client_id: userPool.clientId,
          redirect_uri: AuthSession.getRedirectUrl()
        }
        const formBody = Object.keys(details)
          .map(
            key =&gt; `${encodeURIComponent(key)}=${encodeURIComponent(details[key])}`
          )
          .join("&amp;");
  
        await fetch(
          tokenURL,
          {
            method: "POST",
            headers: {
              'Content-type': 'application/x-www-form-urlencoded;charset=UTF-8'
            },
            body: formBody
          }
        )
          .then(async (res) =&gt; {
            let tokenRequestJson = await res.json();
            const IdToken = new CognitoIdToken({ IdToken: tokenRequestJson.id_token });
            const AccessToken = new CognitoAccessToken({ AccessToken: tokenRequestJson.access_token });
            const RefreshToken = new CognitoRefreshToken({ RefreshToken: tokenRequestJson.refresh_token })
            try {
              let userSession = new CognitoUserSession({ IdToken, AccessToken, RefreshToken });
              const userData = {
                Username: userSession.idToken.payload.email,
                Pool: userPool
              };
  
              cognitoUser = new CognitoUser(userData);
              cognitoUser.setSignInUserSession(userSession);
              cognitoUser.getSession(async (err, session) =&gt; { // You must run this to verify that session (internally)
                if (session.isValid()) {
  
                  // EVERYTHING WORKS UP TO HERE &lt;!----------------&gt;
  
                  let cognitoUser = await Auth.currentAuthenticatedUser()
                  this.setState({user: cognitoUser})
  
                  this.props.navigation.navigate('AuthLoading', {user: cognitoUser})
                } else {
                  console.log('session is not valid: ', session);
                }
              })
            }
            catch (FBSignInError) {
              console.log('FBSignInError: ', FBSignInError)
            }
          })
          .catch(error =&gt; {
            console.log('error: ', error);
          });
      }
  </code></pre>