title: Amplify authentication with angular: error retrieving currentUserInfo
body: <p>I am having an issue, when I trying to get the user info, iam getting null in my method isAuthenticated in the instruction <code>Auth.currentUserInfo()</code>; and user not signed, when I try with <code>Auth.currentAuthenticatedUser()</code>. I have searched for different solutions but I had not could fix the problem.</p>
  <p>I leave some of my code. I hope somebody could help me:</p>
  <p>My app.module amplyfy configuration is</p>
  <pre><code>Amplify.configure({
    Auth: {
      mandatorySignIn: false,
      region: amplifyConfig.cognito.REGION,
      userPoolId: amplifyConfig.cognito.USER_POOL_ID,
      userPoolWebClientId: amplifyConfig.cognito.APP_CLIENT_ID,
      oauth: {
        domain: amplifyConfig.cognito.DOMAIN,
        scope: amplifyConfig.cognito.SCOPE,
        responseType: amplifyConfig.cognito.RESPONSE_TYPE
      }
    }
  });
  </code></pre>
  <p>my dependencys in package.json are:</p>
  <pre><code>&quot;@aws-amplify/api&quot;: &quot;^4.0.45&quot;,
  &quot;@aws-amplify/auth&quot;: &quot;^4.5.9&quot;,
  &quot;@aws-amplify/pubsub&quot;: &quot;^4.4.6&quot;,
  &quot;aws-amplify&quot;: &quot;^3.4.3&quot;,
  &quot;aws-amplify-angular&quot;: &quot;^6.0.26&quot;,
  </code></pre>
  <p>and my cognito service is:</p>
  <pre><code>import { Injectable } from '@angular/core';
  import { Auth } from &quot;aws-amplify&quot;;
  import { BehaviorSubject } from 'rxjs';
  
  export interface IUser {
    userName: string;
    password: string;
  }
  
  @Injectable({
    providedIn: 'root'
  })
  export class CognitoService {
  
    authenticationSubject: BehaviorSubject&lt;boolean&gt; = new BehaviorSubject&lt;boolean&gt;(false);
  
    constructor() {
      this.isAuthenticated().then(r =&gt; {this.authenticationSubject.next(r)});
    }
  
    public signUp(user: IUser): Promise&lt;any&gt; {
      return Auth.signUp({
        username: user.userName,
        password: user.password,
      });
    }
  
    public confirmSignUp(user: IUser): Promise&lt;any&gt; {
      return Auth.confirmSignUp(user.userName, '');
    }
  
    public async signIn(user: IUser, rememberUser: boolean): Promise&lt;boolean&gt; {
      try {
        await Auth.signIn(user.userName, user.password);
        this.authenticationSubject.next(true);
        return true;
      } catch (error) {
        console.log('error signing in', error);
        this.authenticationSubject.next(true);
        return false;
      }
    }
  
    public async signOut(): Promise&lt;any&gt; {
      try {
        await Auth.signOut();
        this.authenticationSubject.next(false);
      } catch (error) {
        console.log('error signing out: ', error);
      }
    }
  
    private async isAuthenticated(): Promise&lt;boolean&gt; {
      try {
        let user = await Auth.currentUserInfo();
        return !!user;
      } catch (error) {
        return false;
      }
    }
  
    public async getUser(): Promise&lt;any&gt; {
      return await Auth.currentUserPoolUser();
    }
  
    public updateUser(user: IUser): Promise&lt;any&gt; {
      return Auth.currentUserPoolUser().then((cognitoUser: any) =&gt; {
        return Auth.updateUserAttributes(cognitoUser, user);
      });
    }
  }
  </code></pre>
  <p>thanks for your help</p>