AmplifyException (You are currently signed out) after success Social Sign In

57 views Asked by At

I use amplify for social login in my app. Gradle:

implementation "com.amplifyframework:core:$amplify_version"
implementation "com.amplifyframework:aws-auth-cognito:$amplify_version"

amplify_version = '2.8.5'

In my Application class:

Amplify.addPlugin(new AWSCognitoAuthPlugin());
Amplify.configure(getApplicationContext());

Here is my amplifyconfiguration.json:

{
  "auth": {
    "plugins": {
      "awsCognitoAuthPlugin": {
        "IdentityManager": {
          "Default": {}
        },
        "CredentialsProvider": {
          "CognitoIdentity": {
            "Default": {
              "PoolId": "[Cognito Identity Pull Id]",
              "Region": "us-east-1"
            }
          }
        },
        "CognitoUserPool": {
          "Default": {
            "PoolId": "[User Pool Id]",
            "AppClientId": "[Id]",
            "AppClientSecret": "[Secret]",
            "Region": "us-east-1",
            "WebDomain": "[domain]"
          }
        },
        "Auth": {
          "Default": {
            "authenticationFlowType": "[Flow type by Server Config]",
            "OAuth": {
              "PoolId": "[User Pool Id]",
              "AppClientId": "[Id]",
              "AppClientSecret": "[Secret]",
              "Region": "us-east-1",
              "WebDomain": "[domain]"
              "SignInRedirectURI": "[callback]",
              "SignOutRedirectURI": "[callback]",
              "Scopes": ["openid", "email", "profile", "aws.cognito.signin.user.admin"]
            }
          }
        }
      }
    }
  }
}

Then I use fun signInWithSocialWebUI(...) and it return success, I can fetch tokens and use AWS, but after restart I got error:

AWSCognitoAuthSession{isSignedIn=false, 
awsCredentials=AuthSessionResult{value=null, error=AmplifyException {message=You are currently signed out., cause=null, recoverySuggestion=Please sign in and reattempt the operation.}, type=FAILURE}, 
userSub='AuthSessionResult{value=null, error=AmplifyException {message=You are currently signed out., cause=null, recoverySuggestion=Please sign in and reattempt the operation.}, type=FAILURE}', 
identityId='AuthSessionResult{value=null, error=AmplifyException {message=You are currently signed out., cause=null, recoverySuggestion=Please sign in and reattempt the operation.}, type=FAILURE}', 
userPoolTokens='AuthSessionResult{value=null, error=AmplifyException {message=You are currently signed out., cause=null, recoverySuggestion=Please sign in and reattempt the operation.}, type=FAILURE}'}

How can I fix it? Is something wrong in my config? Now I should do signIn after each restart, this is unaccepable... Btw, everyting is OK in iOS-app.

0

There are 0 answers