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

SignInWithWebUI returning "An error was encountered with the requested page" #2259

Closed akotorri closed 1 year ago

akotorri commented 1 year ago

Description

I'm using an existing userPool which works perfectly on the web app which was made with a different technology and for flutter I'm importing that userPool and adding the plugin in "main.dart" as we should, then call the signInWithWebUI method and provide the "AuthProvider.google" but when I do so "signInWithWebUI()" returns "An error was encountered with the requested page" and not the google auth UI,

Categories

Steps to Reproduce

Import a working userPool with a different app, add the auth plugin on main.dart try to call the singInWithWebUI

Screenshots

Screenshot 2022-10-18 at 15 25 01

Platforms

Android Device/Emulator API Level

API 29, API 30

Environment

[✓] Flutter (Channel stable, 3.3.0, on macOS 12.5.1 21G83 darwin-x64, locale en-GB)
[!] Android toolchain - develop for Android devices (Android SDK version 31.0.0)
    ✗ cmdline-tools component is missing
      Run `path/to/sdkmanager --install "cmdline-tools;latest"`
      See https://developer.android.com/studio/command-line for more details.
    ✗ Android license status unknown.
      Run `flutter doctor --android-licenses` to accept the SDK licenses.
      See https://flutter.dev/docs/get-started/install/macos#android-setup for more details.
[✓] Xcode - develop for iOS and macOS (Xcode 14.0)
[✓] Chrome - develop for the web
[✓] Android Studio (version 2021.1)
[✓] VS Code (version 1.63.0)
[✓] Connected device (3 available)
[✓] HTTP Host Availability

! Doctor found issues in 1 category.

Dependencies

Dart SDK 2.18.0
Flutter SDK 3.3.0
ambra 1.0.0+2

dependencies:
- amazon_cognito_identity_dart_2 3.0.3 [convert crypto http js]
- amplify_auth_cognito 0.6.9 [amplify_auth_cognito_android amplify_auth_cognito_ios amplify_core aws_common collection flutter meta plugin_platform_interface]
- amplify_auth_cognito_ios 0.6.9 [amplify_core flutter]
- amplify_authenticator 0.2.3 [amplify_auth_cognito amplify_core amplify_flutter async aws_common collection flutter flutter_localizations intl stream_transform]
- amplify_flutter 0.6.9 [amplify_core amplify_datastore_plugin_interface amplify_flutter_android amplify_flutter_ios aws_common collection flutter meta plugin_platform_interface]
- cached_network_image 3.2.2 [flutter flutter_cache_manager octo_image cached_network_image_platform_interface cached_network_image_web]
- carousel_slider 4.1.1 [flutter]
- connectivity_plus 2.3.9 [flutter connectivity_plus_platform_interface connectivity_plus_linux connectivity_plus_macos connectivity_plus_web connectivity_plus_windows]
- cupertino_icons 1.0.5
- date_time_picker 2.1.0 [flutter intl]
- device_preview 1.1.0 [flutter flutter_localizations provider device_frame freezed_annotation json_annotation shared_preferences collection]
- drag_and_drop_lists 0.3.3 [flutter]
- file_picker 5.2.1 [flutter flutter_web_plugins flutter_plugin_android_lifecycle plugin_platform_interface ffi path win32]
- filesize 2.0.1
- flutter 0.0.0 [characters collection material_color_utilities meta vector_math sky_engine]
- flutter_colorpicker 0.6.1 [flutter]
- flutter_mentions 2.0.1 [flutter flutter_portal]
- flutter_native_splash 2.2.11 [args flutter flutter_web_plugins html image js meta path universal_io xml yaml]
- flutter_signin_button 2.0.0 [flutter font_awesome_flutter]
- flutter_slidable 2.0.0 [flutter]
- flutter_svg 1.1.5 [flutter meta path_drawing vector_math xml]
- get 4.6.3 [flutter]
- google_fonts 2.3.3 [flutter http path_provider crypto]
- http 0.13.5 [async http_parser meta path]
- internet_connection_checker 0.0.1+4
- intl 0.17.0 [clock path]
- overlay_support 2.0.1 [flutter async]
- pin_code_fields 7.4.0 [flutter]
- shared_preferences 2.0.15 [flutter shared_preferences_android shared_preferences_ios shared_preferences_linux shared_preferences_macos shared_preferences_platform_interface shared_preferences_web shared_preferences_windows]
- smooth_page_indicator 1.0.0+2 [flutter]
- syncfusion_flutter_datepicker 20.3.49 [flutter intl syncfusion_flutter_core]
- url_launcher 6.1.6 [flutter url_launcher_android url_launcher_ios url_launcher_linux url_launcher_macos url_launcher_platform_interface url_launcher_web url_launcher_windows]
- uuid 3.0.6 [crypto]
- webview_flutter 3.0.4 [flutter webview_flutter_android webview_flutter_platform_interface webview_flutter_wkwebview]

transitive dependencies:
- amplify_auth_cognito_android 0.6.9 [flutter]
- amplify_core 0.6.9 [aws_common collection flutter intl json_annotation meta plugin_platform_interface uuid]
- amplify_datastore_plugin_interface 0.6.9 [amplify_core collection flutter meta]
- amplify_flutter_android 0.6.9 [flutter]
- amplify_flutter_ios 0.6.9 [amplify_core flutter]
- archive 3.3.2 [crypto path]
- args 2.3.1
- async 2.9.0 [collection meta]
- aws_common 0.1.1 [async collection http meta stream_transform uuid]
- cached_network_image_platform_interface 2.0.0 [flutter flutter_cache_manager]
- cached_network_image_web 1.0.2 [flutter flutter_cache_manager cached_network_image_platform_interface]
- characters 1.2.1
- clock 1.1.1
- collection 1.16.0
- connectivity_plus_linux 1.3.1 [flutter connectivity_plus_platform_interface meta nm]
- connectivity_plus_macos 1.2.6 [connectivity_plus_platform_interface flutter]
- connectivity_plus_platform_interface 1.2.1 [flutter meta plugin_platform_interface]
- connectivity_plus_web 1.2.5 [connectivity_plus_platform_interface flutter_web_plugins flutter js]
- connectivity_plus_windows 1.2.2 [connectivity_plus_platform_interface flutter]
- convert 3.1.1 [typed_data]
- crypto 3.0.2 [typed_data]
- csslib 0.17.2 [source_span]
- dbus 0.7.8 [args ffi meta xml]
- device_frame 1.1.0 [freezed_annotation flutter]
- ffi 2.0.1
- file 6.1.4 [meta path]
- flutter_blurhash 0.7.0 [flutter]
- flutter_cache_manager 3.3.0 [clock collection file flutter http path path_provider pedantic rxdart sqflite uuid]
- flutter_localizations 0.0.0 [flutter intl characters clock collection material_color_utilities meta path vector_math]
- flutter_plugin_android_lifecycle 2.0.7 [flutter]
- flutter_portal 0.4.0 [flutter]
- flutter_web_plugins 0.0.0 [flutter js characters collection material_color_utilities meta vector_math]
- font_awesome_flutter 9.2.0 [flutter]
- freezed_annotation 2.2.0 [collection json_annotation meta]
- html 0.15.0 [csslib source_span]
- http_parser 4.0.2 [collection source_span string_scanner typed_data]
- image 3.2.2 [archive meta xml]
- js 0.6.4
- json_annotation 4.7.0 [meta]
- material_color_utilities 0.1.5
- meta 1.8.0
- nested 1.0.0 [flutter]
- nm 0.5.0 [dbus]
- octo_image 1.0.2 [flutter flutter_blurhash]
- path 1.8.2
- path_drawing 1.0.1 [vector_math meta path_parsing flutter]
- path_parsing 1.0.1 [vector_math meta]
- path_provider 2.0.11 [flutter path_provider_android path_provider_ios path_provider_linux path_provider_macos path_provider_platform_interface path_provider_windows]
- path_provider_android 2.0.20 [flutter path_provider_platform_interface]
- path_provider_ios 2.0.11 [flutter path_provider_platform_interface]
- path_provider_linux 2.1.7 [ffi flutter path path_provider_platform_interface xdg_directories]
- path_provider_macos 2.0.6 [flutter path_provider_platform_interface]
- path_provider_platform_interface 2.0.5 [flutter platform plugin_platform_interface]
- path_provider_windows 2.1.3 [ffi flutter path path_provider_platform_interface win32]
- pedantic 1.11.1
- petitparser 5.0.0 [meta]
- platform 3.1.0
- plugin_platform_interface 2.1.3 [meta]
- process 4.2.4 [file path platform]
- provider 6.0.4 [collection flutter nested]
- rxdart 0.27.5
- shared_preferences_android 2.0.14 [flutter shared_preferences_platform_interface]
- shared_preferences_ios 2.1.1 [flutter shared_preferences_platform_interface]
- shared_preferences_linux 2.1.1 [file flutter path path_provider_linux path_provider_platform_interface shared_preferences_platform_interface]
- shared_preferences_macos 2.0.4 [flutter shared_preferences_platform_interface]
- shared_preferences_platform_interface 2.1.0 [flutter plugin_platform_interface]
- shared_preferences_web 2.0.4 [flutter flutter_web_plugins shared_preferences_platform_interface]
- shared_preferences_windows 2.1.1 [file flutter path path_provider_platform_interface path_provider_windows shared_preferences_platform_interface]
- sky_engine 0.0.99
- source_span 1.9.0 [collection path term_glyph]
- sqflite 2.1.0+1 [flutter sqflite_common path]
- sqflite_common 2.3.0 [synchronized path meta]
- stream_transform 2.0.1
- string_scanner 1.1.1 [source_span]
- syncfusion_flutter_core 20.3.49 [vector_math flutter]
- synchronized 3.0.0+3
- term_glyph 1.2.1
- typed_data 1.3.1 [collection]
- universal_io 2.0.4 [collection crypto meta typed_data]
- url_launcher_android 6.0.19 [flutter url_launcher_platform_interface]
- url_launcher_ios 6.0.17 [flutter url_launcher_platform_interface]
- url_launcher_linux 3.0.1 [flutter url_launcher_platform_interface]
- url_launcher_macos 3.0.1 [flutter url_launcher_platform_interface]
- url_launcher_platform_interface 2.1.1 [flutter plugin_platform_interface]
- url_launcher_web 2.0.13 [flutter flutter_web_plugins url_launcher_platform_interface]
- url_launcher_windows 3.0.1 [flutter url_launcher_platform_interface]
- vector_math 2.1.2
- webview_flutter_android 2.10.4 [flutter webview_flutter_platform_interface]
- webview_flutter_platform_interface 1.9.5 [flutter meta plugin_platform_interface]
- webview_flutter_wkwebview 2.9.5 [flutter path webview_flutter_platform_interface]
- win32 3.0.1 [ffi]
- xdg_directories 0.2.0+2 [meta path process]
- xml 6.1.0 [collection meta petitparser]
- yaml 3.1.1 [collection source_span string_scanner]

Device

N/A

OS

N/A

Deployment Method

Amplify CLI

CLI Version

10.0.0

Additional Context

No response

Amplify Config

const amplifyconfig = ''' { "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": "-------", "Region": "us-east-1" } } }, "CognitoUserPool": { "Default": { "PoolId": "-------", "AppClientId": "-------", "Region": "us-east-1" } }, "Auth": { "Default": { "OAuth": { "WebDomain": "-------.auth.us-east-1.amazoncognito.com", "AppClientId": "-------", "SignInRedirectURI": "http://localhost:4200/auth,https://-------.net/auth,myapp://", "SignOutRedirectURI": "http://localhost:4200/auth,https://-------.net/auth,myapp://", "Scopes": [ "aws.cognito.signin.user.admin", "email", "openid", "profile" ] }, "authenticationFlowType": "CUSTOM_AUTH", "socialProviders": [ "GOOGLE" ], "usernameAttributes": [ "EMAIL" ], "signupAttributes": [ "NAME", "EMAIL" ], "passwordProtectionSettings": { "passwordPolicyMinLength": 8, "passwordPolicyCharacters": [] }, "mfaConfiguration": "OFF", "mfaTypes": [], "verificationMechanisms": [] } }, "S3TransferUtility": { "Default": { "Bucket": "-------", "Region": "us-east-2" } } } } }, "storage": { "plugins": { "awsS3StoragePlugin": { "bucket": "-------", "region": "us-east-2", "defaultAccessLevel": "guest" } } } }''';

dnys1 commented 1 year ago

Hi @akotorri - I believe the issue is that in current Amplify versions, only the first redirect URI is considered when using Hosted UI. In your case, that is a localhost address which cannot be used on mobile devices. You can try moving your myapp URI to the front of the list, which should resolve the issue.

Alternatively, please feel free to check out our vNext which is currently in dev-preview but properly handles this situation:

dependencies:
  amplify_auth_cognito: ^1.0.0-0
  amplify_authenticator: ^1.0.0-0
  amplify_flutter: ^1.0.0-0
akotorri commented 1 year ago

@dnys1 thank you for the reply, just wanted to let you know that I did upgrade my dependencies to 1.0.0-0 and it fixed the issue with google auth and it also fixed the costume authentication that previously didn’t work for me as well, thank you 😊.