aws-amplify / amplify-flutter

A declarative library with an easy-to-use interface for building Flutter applications on AWS.
https://docs.amplify.aws
Apache License 2.0
1.31k stars 243 forks source link

UnknownException: Unable to get valid sign in session from the end user. #2312

Closed wrbl606 closed 1 year ago

wrbl606 commented 1 year ago

Description

Users previously authenticated with Cognito started generating the error below after an application update, which wasn't related to AWS Cognito API implementation or usage.

UnknownException(message: Unexpected error occurred with message: Unable to get valid sign in session from the end user., recoverySuggestion: This should not happen. There is a possibility that there is a bug if this error persists. Please take a look at https://github.com/aws-amplify/amplify-ios/issues to see if there are any existing issues that match your scenario, and file an issue with the details of the bug if there isn't. Issue encountered at: file: /Users/builder/clone/ios/Pods/Amplify/Amplify/Categories/Auth/Error/AuthError.swift function: recoverySuggestion line: 80, underlyingException: null)

This happens consistently, reinstalling application does not fix the issue as the logged-in state persists. It affects only iOS users, Android version works perfectly fine. The main problem is that it doesn't reproduce locally on development machines so we can't experiment nor provide much more context to this issue.

This exception is thrown during AmplifyAuthCognitoMethodChannel.fetchUserAttributes call (line 297 in method_channel_auth_cognito.dart).

Categories

Steps to Reproduce

No response

Screenshots

No response

Platforms

Android Device/Emulator API Level

No response

Environment

Doctor summary (to see all details, run flutter doctor -v):
[✓] Flutter (Channel stable, 3.3.5, on macOS 13.0 22A380 darwin-x64, locale en-PL)
[✓] Android toolchain - develop for Android devices (Android SDK version 33.0.0)
[✓] Xcode - develop for iOS and macOS (Xcode 14.1)
[✓] Chrome - develop for the web
[✓] Android Studio (version 2021.3)
[✓] VS Code (version 1.73.0)
[✓] Connected device (4 available)
[✓] HTTP Host Availability

• No issues found!

Dependencies

+ _fe_analyzer_shared 50.0.0
+ _flutterfire_internals 1.0.2 (1.0.6 available)
+ advertising_id 2.3.0
+ amplify_auth_cognito 0.6.9
+ amplify_auth_cognito_android 0.6.9
+ amplify_auth_cognito_ios 0.6.9
+ amplify_core 0.6.9
+ amplify_datastore_plugin_interface 0.6.9
+ amplify_flutter 0.6.9
+ amplify_flutter_android 0.6.9
+ amplify_flutter_ios 0.6.9
+ analyzer 5.2.0
+ analyzer_plugin 0.11.2
+ ansicolor 2.0.1
+ app_tracking_transparency 2.0.3
+ archive 3.3.0 (3.3.2 available)
+ args 2.3.1
+ async 2.9.0 (2.10.0 available)
+ auto_size_text 3.0.0
+ aws_common 0.1.1 (0.2.4 available)
+ boolean_selector 2.1.0 (2.1.1 available)
+ braze_plugin 2.6.0
+ build 2.3.1
+ build_config 1.1.1
+ build_daemon 3.1.0
+ build_resolvers 2.1.0
+ build_runner 2.3.2
+ build_runner_core 7.2.7
+ built_collection 5.1.1
+ built_value 8.4.2
+ cached_network_image 3.2.2
+ cached_network_image_platform_interface 2.0.0
+ cached_network_image_web 1.0.2
+ carousel_slider 4.1.1
+ change_app_package_name 1.1.0
+ characters 1.2.1
+ checked_yaml 2.0.1
+ clock 1.1.1
+ cloud_firestore_platform_interface 5.7.7 (5.8.3 available)
+ cloud_firestore_web 2.8.10 (3.0.3 available)
+ code_builder 4.3.0
+ collection 1.16.0 (1.17.0 available)
+ connectivity 3.0.6 (discontinued)
+ connectivity_for_web 0.4.0+1
+ connectivity_macos 0.2.1+2
+ connectivity_platform_interface 2.0.1
+ convert 3.1.1
+ country_code_picker 2.0.2 (discontinued)
+ cross_file 0.3.3+2
+ crypto 3.0.2
+ csslib 0.17.2
+ cupertino_will_pop_scope 1.2.1
+ custom_rounded_rectangle_border 0.2.0-nullsafety.0
+ dart_code_metrics 5.0.0
+ dart_style 2.2.4
+ dbus 0.7.8
+ device_info_plus 4.1.3 (8.0.0 available)
+ device_info_plus_linux 3.0.0 (5.0.0 available)
+ device_info_plus_macos 3.0.0 (5.0.0 available)
+ device_info_plus_platform_interface 3.0.0 (7.0.0 available)
+ device_info_plus_web 3.0.0 (5.0.0 available)
+ device_info_plus_windows 4.1.0 (6.0.0 available)
+ dio 4.0.6
+ email_validator 2.1.17
+ equatable 2.0.5
+ fake_async 1.3.1
+ fast_immutable_collections 7.4.3 (8.0.0 available)
+ ffi 2.0.1
+ file 6.1.2 (6.1.4 available)
+ firebase_core 1.24.0 (2.1.1 available)
+ firebase_core_platform_interface 4.5.1 (4.5.2 available)
+ firebase_core_web 1.7.3 (2.0.1 available)
+ firebase_messaging 13.1.0 (14.0.3 available)
+ firebase_messaging_platform_interface 4.2.0 (4.2.4 available)
+ firebase_messaging_web 3.2.0 (3.2.4 available)
+ fixnum 1.0.1
+ fluro 2.0.3
+ flutter 0.0.0 from sdk flutter
+ flutter_blurhash 0.7.0
+ flutter_cache_manager 3.3.0
+ flutter_countdown_timer 4.1.0
+ flutter_driver 0.0.0 from sdk flutter
+ flutter_dynamic_icon 2.1.0
+ flutter_html 3.0.0-alpha.6
+ flutter_keyboard_visibility 5.4.0
+ flutter_keyboard_visibility_linux 1.0.0
+ flutter_keyboard_visibility_macos 1.0.0
+ flutter_keyboard_visibility_platform_interface 2.0.0
+ flutter_keyboard_visibility_web 2.0.0
+ flutter_keyboard_visibility_windows 1.0.0
+ flutter_launcher_icons 0.9.3 (0.10.0 available)
+ flutter_lints 2.0.1
+ flutter_local_notifications 9.9.1 (12.0.3 available)
+ flutter_local_notifications_linux 0.5.1 (2.0.0 available)
+ flutter_local_notifications_platform_interface 5.0.0 (6.0.0 available)
+ flutter_localizations 0.0.0 from sdk flutter
+ flutter_native_splash 2.2.13
+ flutter_native_timezone 2.0.0
+ flutter_plugin_android_lifecycle 2.0.7
+ flutter_segment 3.13.0 from git https://github.com/wrbl606/flutter-segment.git at bb71fb
+ flutter_smartlook 3.0.10 (4.0.3 available)
+ flutter_stripe 3.3.0 (6.0.0 available)
+ flutter_test 0.0.0 from sdk flutter
+ flutter_typeahead 4.1.1
+ flutter_web_plugins 0.0.0 from sdk flutter
+ flutter_widget_from_html_core 0.8.5+3 (0.9.0 available)
+ freezed_annotation 2.2.0
+ frontend_server_client 3.1.0
+ fuchsia_remote_debug_protocol 0.0.0 from sdk flutter
+ fwfh_text_style 2.22.08+1
+ geocoding 2.0.5
+ geocoding_platform_interface 2.0.1
+ geolocator 8.2.1 (9.0.2 available)
+ geolocator_android 3.2.1 (4.1.4 available)
+ geolocator_apple 2.2.3
+ geolocator_platform_interface 4.0.7
+ geolocator_web 2.1.6
+ geolocator_windows 0.1.1
+ get_it 7.2.0
+ glob 2.1.0
+ google_maps_flutter 2.2.1
+ google_maps_flutter_android 2.3.3
+ google_maps_flutter_ios 2.1.12
+ google_maps_flutter_platform_interface 2.2.4
+ google_maps_webservice 0.0.20-nullsafety.5
+ graphs 2.2.0
+ html 0.15.1
+ http 0.13.5
+ http_multi_server 3.2.1
+ http_parser 4.0.2
+ image 3.2.2
+ integration_test 0.0.0 from sdk flutter
+ intercom_flutter 7.5.0
+ intercom_flutter_platform_interface 1.2.1
+ intercom_flutter_web 0.2.1
+ intl 0.17.0
+ io 1.0.3
+ js 0.6.4 (0.6.5 available)
+ json_annotation 4.7.0
+ jwt_decode 0.3.1
+ lints 2.0.1
+ logging 1.1.0
+ loggy 2.0.1+1
+ matcher 0.12.12 (0.12.13 available)
+ material_color_utilities 0.1.5 (0.2.0 available)
+ meta 1.8.0
+ mime 1.0.2
+ mockito 5.3.2
+ modal_bottom_sheet 2.1.2
+ nested 1.0.0
+ numerus 2.0.0
+ octo_image 1.0.2
+ package_config 2.1.0
+ package_info_plus 1.4.3+1 (3.0.1 available)
+ package_info_plus_linux 1.0.5 (2.0.0 available)
+ package_info_plus_macos 1.3.0 (2.0.0 available)
+ package_info_plus_platform_interface 1.0.2 (2.0.1 available)
+ package_info_plus_web 1.0.6 (2.0.0 available)
+ package_info_plus_windows 2.1.0 (3.0.0 available)
+ path 1.8.2
+ path_provider 2.0.11
+ path_provider_android 2.0.21
+ path_provider_ios 2.0.11
+ path_provider_linux 2.1.7
+ path_provider_macos 2.0.6
+ path_provider_platform_interface 2.0.5
+ path_provider_windows 2.1.3
+ pedantic 1.11.1
+ petitparser 5.1.0
+ pin_code_fields 7.4.0
+ platform 3.1.0
+ plugin_platform_interface 2.1.3
+ pool 1.5.1
+ process 4.2.4
+ provider 6.0.4
+ pub_semver 2.1.2
+ pub_updater 0.2.2
+ pubspec_parse 1.2.1
+ rxdart 0.27.5
+ sentry 6.13.1
+ sentry_dio 6.13.1
+ sentry_flutter 6.13.1
+ share_plus 4.5.3 (6.2.0 available)
+ share_plus_linux 3.0.1
+ share_plus_macos 3.0.1
+ share_plus_platform_interface 3.2.0
+ share_plus_web 3.1.0
+ share_plus_windows 3.0.1 (4.0.0 available)
+ shared_preferences 2.0.15
+ shared_preferences_android 2.0.14
+ shared_preferences_ios 2.1.1
+ shared_preferences_linux 2.1.1
+ shared_preferences_macos 2.0.4
+ shared_preferences_platform_interface 2.1.0
+ shared_preferences_web 2.0.4
+ shared_preferences_windows 2.1.1
+ shelf 1.4.0
+ shelf_web_socket 1.0.2
+ shimmer_animation 2.1.0+1
+ sky_engine 0.0.99 from sdk flutter
+ source_gen 1.2.6
+ source_span 1.9.0 (1.9.1 available)
+ sqflite 2.2.0+3
+ sqflite_common 2.4.0+2
+ stack_trace 1.10.0 (1.11.0 available)
+ store_redirect 2.0.1
+ stream_channel 2.1.0 (2.1.1 available)
+ stream_transform 2.0.1
+ string_scanner 1.1.1 (1.2.0 available)
+ stripe_android 3.3.0 (6.0.0 available)
+ stripe_ios 3.3.0 (6.0.0 available)
+ stripe_platform_interface 3.3.0 (6.0.0 available)
+ sync_http 0.3.1
+ synchronized 3.0.0+3
+ term_glyph 1.2.1
+ test_api 0.4.12 (0.4.16 available)
+ throttling 1.0.0
+ timezone 0.8.0 (0.9.0 available)
+ timing 1.0.0
+ truncate 3.0.1
+ typed_data 1.3.1
+ universal_io 2.0.4
+ universal_platform 1.0.0+1
+ url_launcher 6.1.6
+ url_launcher_android 6.0.21
+ url_launcher_ios 6.0.17
+ url_launcher_linux 3.0.1
+ url_launcher_macos 3.0.1
+ url_launcher_platform_interface 2.1.1
+ url_launcher_web 2.0.13
+ url_launcher_windows 3.0.1
+ url_strategy 0.2.0
+ uuid 3.0.6
+ vector_math 2.1.2 (2.1.4 available)
+ version 2.0.3 (3.0.2 available)
+ vm_service 9.0.0 (9.4.0 available)
+ watcher 1.0.2
+ web_socket_channel 2.2.0
+ webdriver 3.0.0 (3.0.1 available)
+ webview_flutter 3.0.4
+ webview_flutter_android 2.10.4
+ webview_flutter_platform_interface 1.9.5
+ webview_flutter_wkwebview 2.9.5
+ win32 3.0.1
+ xdg_directories 0.2.0+2
+ xml 6.1.0 (6.2.0 available)
+ yaml 3.1.1

Device

iPhone 7 Plus, iPhone 12 Pro, iPhone14,4, iPhone SE (2nd generation), iPhone15,2

OS

iOS 16.0.2, iOS 16.0, iOS 14.7.1, iOS 15.6.1, iOS 15.7.1

Deployment Method

Amplify CLI

CLI Version

No response

Additional Context

No response

Amplify Config

{
    "UserAgent": "aws-amplify-cli/2.0",
    "Version": "1.0",
    "auth": {
        "plugins": {
            "awsCognitoAuthPlugin": {
                "UserAgent": "aws-amplify-cli/0.1.0",
                "Version": "0.1.0",
                "IdentityManager": {
                    "Default": {}
                },
                "CredentialsProvider": {
                    "CognitoIdentity": {
                        "Default": {
                            "PoolId": "eu-central-1:***",
                            "Region": "eu-central-1"
                        }
                    }
                },
                "CognitoUserPool": {
                    "Default": {
                        "PoolId": "eu-central-1***",
                        "AppClientId": "***",
                        "Region": "eu-central-1"
                    }
                },
                "Auth": {
                    "Default": {
                        "OAuth": {
                            "WebDomain": "***",
                            "AppClientId": "***",
                            "SignInRedirectURI": "***://",
                            "SignOutRedirectURI": "***://",
                            "Scopes": [
                                "phone",
                                "email",
                                "openid",
                                "profile",
                                "aws.cognito.signin.user.admin"
                            ]
                        },
                        "authenticationFlowType": "USER_SRP_AUTH",
                        "socialProviders": [
                            "GOOGLE",
                            "APPLE"
                        ],
                        "usernameAttributes": [
                            "EMAIL"
                        ],
                        "signupAttributes": [
                            "EMAIL"
                        ],
                        "passwordProtectionSettings": {
                            "passwordPolicyMinLength": 8,
                            "passwordPolicyCharacters": []
                        },
                        "mfaConfiguration": "OFF",
                        "mfaTypes": [
                            "SMS"
                        ],
                        "verificationMechanisms": [
                            "EMAIL"
                        ]
                    }
                }
            }
        }
    }
}
michaeljajou commented 1 year ago

I am also experiencing this issue (not on all devices, it seems to be pretty rare)

iPhone 14 iOS 16.0.2

michaeljajou commented 1 year ago

This issue is also mentioned here: https://github.com/aws-amplify/amplify-swift/issues/2527#issue-1431699016

This seems like an urgent issue and should receive attention immediately.

dnys1 commented 1 year ago

Hi @wrbl606 - sorry you are facing this issue and thank you for the detailed report. Do you believe it's the same issue from the linked Amplify Swift issue?

At the moment, we are dependent on the Amplify Swift team for any changes to the v0.x Auth libraries. It's possible this issue has been resolved in our preview release of the Dart rewrite, v1.0.0-0, and if not, it will be much easier for our team to investigate and make changes with this version.

I understand if you're not able to use it at the moment and can leave this issue open until either the Swift issue is resolved or our Dart release becomes stable. Please continue to work with the Swift team to resolve the underlying issue and thanks for your patience.

wrbl606 commented 1 year ago

Will the v1.0.0 have the same API for end users?

dnys1 commented 1 year ago

Yes, it will have the same API. We've tried to limit breaking changes to the absolute minimum. However, we have needed to make some, mostly around type refinement and improved consistency.

Jordan-Nelson commented 1 year ago

@wrbl606 @michaeljajou - There was a fix released for this in the underlying iOS SDK that Amplify-Flutter depends on. You should be able to get this update by running pod update Amplify AWSPluginsCore AmplifyPlugins from your /ios dir. You can confirm that the version with the fix is being used by looking for the version of AWSCore listed in /ios/Podfile.lock. The version with the fix is v2.28.2.

Please let us know if you are still seeing this issue after updating. Thanks.

Edit: Correction - Pulling in this fix will require a new release from Amplify-Flutter. We have a PR open to pull in the new version in Amplify-Flutter.

dnys1 commented 1 year ago

The iOS fix for this has been published in version 0.6.10 of the library. Would those experiencing the issue be able to test on this version and confirm it is fixed?

wrbl606 commented 1 year ago

We've released a new version of the app with updated dependency and the issue is not reported anymore 👍

dnys1 commented 1 year ago

That's great to hear. Thanks for confirming.

Closing this issue as resolved. Please let us know if you continue to experience issues.