furaiev / amazon-cognito-identity-dart-2

Unofficial Amazon Cognito Identity Provider Dart SDK, to easily add user sign-up and sign-in to your mobile and web apps with AWS.
MIT License
182 stars 113 forks source link

CognitoClientException{statusCode: null, code: Unknown error, name: null, message: Unknown Error) #220

Closed ductranit closed 1 year ago

ductranit commented 1 year ago

I got too many error report from firebase crashlytics like this:

Fatal Exception: io.flutter.plugins.firebase.crashlytics.FlutterError: CognitoClientException{statusCode: null, code: Unknown error, name: null, message: Unknown Error}. Error thrown null.
       at Client.request(client.dart:55)
       at CognitoUser.refreshSession(cognito_user.dart:280)
       at UserSession._initialized(cognito_azure_user.dart:370)
       at UserSession.hasSignedIn(cognito_azure_user.dart:131)
       at AppConfig.init(app.dart:186)
       at SplashWidget._onStart(main.dart:314)

This happens on android devices while the starting app. I'm using this code to check whether user sign in or not

CognitoUser? _cognitoUser;
CognitoUserSession? _session;

Future<bool> _checkAuthenticated() async {
    if (_cognitoUser == null) {
      return false;
    }

   _session = await _cognitoUser!.getSession();
    var isValid = _session!.isValid();
    return isValid;
  }

Where am I wrong?

ecoant commented 1 year ago

EDIT: I just ran into this after some refactoring and revamping. Turns out something I did wiped the entitlements on my macOS desktop app. Needed to put these back in the runner files as described here: https://docs.flutter.dev/development/platform-integration/macos/building#setting-up-entitlements

<key>com.apple.security.network.server</key>
<true/>
<key>com.apple.security.network.client</key>
<true/>
ductranit commented 1 year ago

I got the same issue until now even add network keys

<key>com.apple.security.network.server</key>
<true/>
<key>com.apple.security.network.client</key>
<true/>
github-actions[bot] commented 1 year ago

This issue is stale because it has been open for 30 days with no activity.

github-actions[bot] commented 1 year ago

This issue was closed because it has been inactive for 14 days since being marked as stale.