Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support basic sign in and hosted UI sign in in same app #1207

Closed
niyonx opened this issue Dec 13, 2021 · 12 comments
Closed

Support basic sign in and hosted UI sign in in same app #1207

niyonx opened this issue Dec 13, 2021 · 12 comments
Assignees
Labels
Android Issues specific to the Android Platform auth Issues related to the Auth Category pending-close-response-required The issue will be closed if details necessary to reproduce the issue are not provided within 7 days. pending-triage This issue is in the backlog of issues to triage

Comments

@niyonx
Copy link

niyonx commented Dec 13, 2021

Describe the bug
Can't we use both normal username password sign in and social sign in?

To Reproduce
Steps to reproduce the behavior:

  1. Have both username/ password signin and social signin in the same app

Expected behavior
D/AWSMobileClient(20596): Using the SignInProviderConfig from `awsconfiguration.json`. W/AWSMobileClient(20596): Failed to parse HostedUI settings from store. Defaulting to awsconfiguration.json W/AWSMobileClient(20596): java.lang.NullPointerException: Attempt to invoke virtual method 'int java.lang.String.length()' on a null object reference W/AWSMobileClient(20596): at org.json.JSONTokener.nextCleanInternal(JSONTokener.java:121) W/AWSMobileClient(20596): at org.json.JSONTokener.nextValue(JSONTokener.java:98) W/AWSMobileClient(20596): at org.json.JSONObject.<init>(JSONObject.java:165) W/AWSMobileClient(20596): at org.json.JSONObject.<init>(JSONObject.java:182) W/AWSMobileClient(20596): at com.amazonaws.mobile.client.AWSMobileClient.getHostedUIJSON(AWSMobileClient.java:713) W/AWSMobileClient(20596): at com.amazonaws.mobile.client.AWSMobileClient$2.run(AWSMobileClient.java:614) W/AWSMobileClient(20596): at com.amazonaws.mobile.client.internal.InternalCallback$1.run(InternalCallback.java:101) W/AWSMobileClient(20596): at java.lang.Thread.run(Thread.java:923) D

Platform
Amplify Flutter current supports iOS and Android. This issue is reproducible in (check all that apply):
[x] Android
[] iOS

@HuiSF
Copy link
Member

HuiSF commented Dec 13, 2021

Hi @niyonx thanks for opening this issue.

Username and social login should be able to configured at the same time. Looking at the error logs you pasted, it contains awsconfiguration.json which seems odd, as in amplify-flutter this file is not in the scope.

Could you provide some details to help us understand this issue?

What version of amplify-flutter libraries you are using? (can paste the content of pubspec.lock file)

Have both username/ password signin and social signin in the same app
How did you configure?

Also could you paste the content of the generated amplifyconfiguration.dart?

@HuiSF HuiSF added the auth Issues related to the Auth Category label Dec 13, 2021
@niyonx
Copy link
Author

niyonx commented Dec 13, 2021

Yes I'm not sure why it is using the awsconfiguration.json instead of the amplifyconfiguration.dart. Here is the contents of pubspec.lock.

pubspec.lock
# Generated by pub
# See https://dart.dev/tools/pub/glossary#lockfile
packages:
  amplify_analytics_plugin_interface:
    dependency: transitive
    description:
      name: amplify_analytics_plugin_interface
      url: "https://pub.dartlang.org"
    source: hosted
    version: "0.2.10"
  amplify_api_plugin_interface:
    dependency: transitive
    description:
      name: amplify_api_plugin_interface
      url: "https://pub.dartlang.org"
    source: hosted
    version: "0.2.10"
  amplify_auth_cognito:
    dependency: "direct main"
    description:
      name: amplify_auth_cognito
      url: "https://pub.dartlang.org"
    source: hosted
    version: "0.2.10"
  amplify_auth_plugin_interface:
    dependency: transitive
    description:
      name: amplify_auth_plugin_interface
      url: "https://pub.dartlang.org"
    source: hosted
    version: "0.2.10"
  amplify_core:
    dependency: transitive
    description:
      name: amplify_core
      url: "https://pub.dartlang.org"
    source: hosted
    version: "0.2.10"
  amplify_datastore_plugin_interface:
    dependency: transitive
    description:
      name: amplify_datastore_plugin_interface
      url: "https://pub.dartlang.org"
    source: hosted
    version: "0.2.10"
  amplify_flutter:
    dependency: "direct main"
    description:
      name: amplify_flutter
      url: "https://pub.dartlang.org"
    source: hosted
    version: "0.2.10"
  amplify_storage_plugin_interface:
    dependency: transitive
    description:
      name: amplify_storage_plugin_interface
      url: "https://pub.dartlang.org"
    source: hosted
    version: "0.2.10"
  amplify_storage_s3:
    dependency: "direct main"
    description:
      name: amplify_storage_s3
      url: "https://pub.dartlang.org"
    source: hosted
    version: "0.2.10"
  archive:
    dependency: transitive
    description:
      name: archive
      url: "https://pub.dartlang.org"
    source: hosted
    version: "3.1.6"
  args:
    dependency: transitive
    description:
      name: args
      url: "https://pub.dartlang.org"
    source: hosted
    version: "2.3.0"
  async:
    dependency: transitive
    description:
      name: async
      url: "https://pub.dartlang.org"
    source: hosted
    version: "2.8.1"
  boolean_selector:
    dependency: transitive
    description:
      name: boolean_selector
      url: "https://pub.dartlang.org"
    source: hosted
    version: "2.1.0"
  carousel_slider:
    dependency: "direct main"
    description:
      name: carousel_slider
      url: "https://pub.dartlang.org"
    source: hosted
    version: "4.0.0"
  characters:
    dependency: transitive
    description:
      name: characters
      url: "https://pub.dartlang.org"
    source: hosted
    version: "1.1.0"
  charcode:
    dependency: transitive
    description:
      name: charcode
      url: "https://pub.dartlang.org"
    source: hosted
    version: "1.3.1"
  clock:
    dependency: transitive
    description:
      name: clock
      url: "https://pub.dartlang.org"
    source: hosted
    version: "1.1.0"
  collection:
    dependency: "direct main"
    description:
      name: collection
      url: "https://pub.dartlang.org"
    source: hosted
    version: "1.15.0"
  country_code_picker:
    dependency: "direct main"
    description:
      name: country_code_picker
      url: "https://pub.dartlang.org"
    source: hosted
    version: "2.0.2"
  crypto:
    dependency: transitive
    description:
      name: crypto
      url: "https://pub.dartlang.org"
    source: hosted
    version: "3.0.1"
  cupertino_icons:
    dependency: "direct main"
    description:
      name: cupertino_icons
      url: "https://pub.dartlang.org"
    source: hosted
    version: "1.0.4"
  date_time_format:
    dependency: transitive
    description:
      name: date_time_format
      url: "https://pub.dartlang.org"
    source: hosted
    version: "2.0.1"
  fake_async:
    dependency: transitive
    description:
      name: fake_async
      url: "https://pub.dartlang.org"
    source: hosted
    version: "1.2.0"
  ffi:
    dependency: transitive
    description:
      name: ffi
      url: "https://pub.dartlang.org"
    source: hosted
    version: "1.1.2"
  flutter:
    dependency: "direct main"
    description: flutter
    source: sdk
    version: "0.0.0"
  flutter_google_places:
    dependency: "direct main"
    description:
      name: flutter_google_places
      url: "https://pub.dartlang.org"
    source: hosted
    version: "0.3.0"
  flutter_icons:
    dependency: "direct main"
    description:
      name: flutter_icons
      url: "https://pub.dartlang.org"
    source: hosted
    version: "1.1.0"
  flutter_launcher_icons:
    dependency: "direct main"
    description:
      name: flutter_launcher_icons
      url: "https://pub.dartlang.org"
    source: hosted
    version: "0.9.2"
  flutter_lints:
    dependency: "direct dev"
    description:
      name: flutter_lints
      url: "https://pub.dartlang.org"
    source: hosted
    version: "1.0.4"
  flutter_secure_storage:
    dependency: "direct main"
    description:
      name: flutter_secure_storage
      url: "https://pub.dartlang.org"
    source: hosted
    version: "5.0.2"
  flutter_secure_storage_linux:
    dependency: transitive
    description:
      name: flutter_secure_storage_linux
      url: "https://pub.dartlang.org"
    source: hosted
    version: "1.1.0"
  flutter_secure_storage_macos:
    dependency: transitive
    description:
      name: flutter_secure_storage_macos
      url: "https://pub.dartlang.org"
    source: hosted
    version: "1.1.0"
  flutter_secure_storage_platform_interface:
    dependency: transitive
    description:
      name: flutter_secure_storage_platform_interface
      url: "https://pub.dartlang.org"
    source: hosted
    version: "1.0.0"
  flutter_secure_storage_web:
    dependency: transitive
    description:
      name: flutter_secure_storage_web
      url: "https://pub.dartlang.org"
    source: hosted
    version: "1.0.2"
  flutter_secure_storage_windows:
    dependency: transitive
    description:
      name: flutter_secure_storage_windows
      url: "https://pub.dartlang.org"
    source: hosted
    version: "1.1.2"
  flutter_switch:
    dependency: "direct main"
    description:
      name: flutter_switch
      url: "https://pub.dartlang.org"
    source: hosted
    version: "0.3.2"
  flutter_test:
    dependency: "direct dev"
    description: flutter
    source: sdk
    version: "0.0.0"
  flutter_web_plugins:
    dependency: transitive
    description: flutter
    source: sdk
    version: "0.0.0"
  font_awesome_flutter:
    dependency: "direct main"
    description:
      name: font_awesome_flutter
      url: "https://pub.dartlang.org"
    source: hosted
    version: "9.2.0"
  getwidget:
    dependency: "direct main"
    description:
      name: getwidget
      url: "https://pub.dartlang.org"
    source: hosted
    version: "2.0.4"
  google_api_headers:
    dependency: transitive
    description:
      name: google_api_headers
      url: "https://pub.dartlang.org"
    source: hosted
    version: "1.1.1"
  google_maps_webservice:
    dependency: transitive
    description:
      name: google_maps_webservice
      url: "https://pub.dartlang.org"
    source: hosted
    version: "0.0.20-nullsafety.5"
  http:
    dependency: "direct main"
    description:
      name: http
      url: "https://pub.dartlang.org"
    source: hosted
    version: "0.13.4"
  http_parser:
    dependency: transitive
    description:
      name: http_parser
      url: "https://pub.dartlang.org"
    source: hosted
    version: "4.0.0"
  http_retry:
    dependency: "direct main"
    description:
      name: http_retry
      url: "https://pub.dartlang.org"
    source: hosted
    version: "0.2.0"
  image:
    dependency: transitive
    description:
      name: image
      url: "https://pub.dartlang.org"
    source: hosted
    version: "3.0.8"
  intl:
    dependency: "direct main"
    description:
      name: intl
      url: "https://pub.dartlang.org"
    source: hosted
    version: "0.17.0"
  js:
    dependency: transitive
    description:
      name: js
      url: "https://pub.dartlang.org"
    source: hosted
    version: "0.6.3"
  json_annotation:
    dependency: transitive
    description:
      name: json_annotation
      url: "https://pub.dartlang.org"
    source: hosted
    version: "4.4.0"
  lints:
    dependency: transitive
    description:
      name: lints
      url: "https://pub.dartlang.org"
    source: hosted
    version: "1.0.1"
  matcher:
    dependency: transitive
    description:
      name: matcher
      url: "https://pub.dartlang.org"
    source: hosted
    version: "0.12.10"
  meta:
    dependency: transitive
    description:
      name: meta
      url: "https://pub.dartlang.org"
    source: hosted
    version: "1.7.0"
  modal_bottom_sheet:
    dependency: transitive
    description:
      name: modal_bottom_sheet
      url: "https://pub.dartlang.org"
    source: hosted
    version: "2.0.0"
  nested:
    dependency: transitive
    description:
      name: nested
      url: "https://pub.dartlang.org"
    source: hosted
    version: "1.0.0"
  package_info_plus:
    dependency: transitive
    description:
      name: package_info_plus
      url: "https://pub.dartlang.org"
    source: hosted
    version: "1.3.0"
  package_info_plus_linux:
    dependency: transitive
    description:
      name: package_info_plus_linux
      url: "https://pub.dartlang.org"
    source: hosted
    version: "1.0.3"
  package_info_plus_macos:
    dependency: transitive
    description:
      name: package_info_plus_macos
      url: "https://pub.dartlang.org"
    source: hosted
    version: "1.3.0"
  package_info_plus_platform_interface:
    dependency: transitive
    description:
      name: package_info_plus_platform_interface
      url: "https://pub.dartlang.org"
    source: hosted
    version: "1.0.2"
  package_info_plus_web:
    dependency: transitive
    description:
      name: package_info_plus_web
      url: "https://pub.dartlang.org"
    source: hosted
    version: "1.0.4"
  package_info_plus_windows:
    dependency: transitive
    description:
      name: package_info_plus_windows
      url: "https://pub.dartlang.org"
    source: hosted
    version: "1.0.4"
  path:
    dependency: transitive
    description:
      name: path
      url: "https://pub.dartlang.org"
    source: hosted
    version: "1.8.0"
  petitparser:
    dependency: transitive
    description:
      name: petitparser
      url: "https://pub.dartlang.org"
    source: hosted
    version: "4.4.0"
  plugin_platform_interface:
    dependency: transitive
    description:
      name: plugin_platform_interface
      url: "https://pub.dartlang.org"
    source: hosted
    version: "2.0.2"
  provider:
    dependency: "direct main"
    description:
      name: provider
      url: "https://pub.dartlang.org"
    source: hosted
    version: "6.0.1"
  rxdart:
    dependency: transitive
    description:
      name: rxdart
      url: "https://pub.dartlang.org"
    source: hosted
    version: "0.26.0"
  scroll_to_index:
    dependency: "direct main"
    description:
      name: scroll_to_index
      url: "https://pub.dartlang.org"
    source: hosted
    version: "2.1.0"
  scrollable_positioned_list:
    dependency: "direct main"
    description:
      name: scrollable_positioned_list
      url: "https://pub.dartlang.org"
    source: hosted
    version: "0.2.3"
  sky_engine:
    dependency: transitive
    description: flutter
    source: sdk
    version: "0.0.99"
  sliding_up_panel:
    dependency: "direct main"
    description:
      name: sliding_up_panel
      url: "https://pub.dartlang.org"
    source: hosted
    version: "2.0.0+1"
  source_span:
    dependency: transitive
    description:
      name: source_span
      url: "https://pub.dartlang.org"
    source: hosted
    version: "1.8.1"
  stack_trace:
    dependency: transitive
    description:
      name: stack_trace
      url: "https://pub.dartlang.org"
    source: hosted
    version: "1.10.0"
  stream_channel:
    dependency: transitive
    description:
      name: stream_channel
      url: "https://pub.dartlang.org"
    source: hosted
    version: "2.1.0"
  string_scanner:
    dependency: transitive
    description:
      name: string_scanner
      url: "https://pub.dartlang.org"
    source: hosted
    version: "1.1.0"
  term_glyph:
    dependency: transitive
    description:
      name: term_glyph
      url: "https://pub.dartlang.org"
    source: hosted
    version: "1.2.0"
  test_api:
    dependency: transitive
    description:
      name: test_api
      url: "https://pub.dartlang.org"
    source: hosted
    version: "0.4.2"
  typed_data:
    dependency: transitive
    description:
      name: typed_data
      url: "https://pub.dartlang.org"
    source: hosted
    version: "1.3.0"
  universal_platform:
    dependency: transitive
    description:
      name: universal_platform
      url: "https://pub.dartlang.org"
    source: hosted
    version: "1.0.0+1"
  uuid:
    dependency: transitive
    description:
      name: uuid
      url: "https://pub.dartlang.org"
    source: hosted
    version: "3.0.5"
  vector_math:
    dependency: transitive
    description:
      name: vector_math
      url: "https://pub.dartlang.org"
    source: hosted
    version: "2.1.0"
  win32:
    dependency: transitive
    description:
      name: win32
      url: "https://pub.dartlang.org"
    source: hosted
    version: "2.3.1"
  xml:
    dependency: transitive
    description:
      name: xml
      url: "https://pub.dartlang.org"
    source: hosted
    version: "5.3.1"
  yaml:
    dependency: transitive
    description:
      name: yaml
      url: "https://pub.dartlang.org"
    source: hosted
    version: "3.1.0"
sdks:
  dart: ">=2.14.0 <3.0.0"
  flutter: ">=2.0.0"

Here is my amplifyconfiguration.dart

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": "us***",
                            "Region": "us***"
                        }
                    }
                },
                "CognitoUserPool": {
                    "Default": {
                        "PoolId": "us***",
                        "AppClientId": "4***",
                        "Region": "us-***"
                    }
                },
                "Auth": {
                    "Default": {
                        "OAuth": {
                            "WebDomain": "****amazoncognito.com",
                            "AppClientId": "4*****",
                            "SignInRedirectURI": "myapp://",
                            "SignOutRedirectURI": "myapp://",
                            "Scopes": [
                                "aws.cognito.signin.user.admin",
                                "email",
                                "openid",
                                "phone",
                                "profile"
                            ]
                        },
                        "authenticationFlowType": "USER_SRP_AUTH",
                        "loginMechanisms": [
                            "PREFERRED_USERNAME"
                        ],
                        "signupAttributes": [],
                        "passwordProtectionSettings": {
                            "passwordPolicyCharacters": []
                        },
                        "mfaTypes": [],
                        "verificationMechanisms": []
                    }
                },
                "S3TransferUtility": {
                    "Default": {
                        "Bucket": "storagebucket*****",
                        "Region": "u*****"
                    }
                }
            }
        }
    },
    "storage": {
        "plugins": {
            "awsS3StoragePlugin": {
                "bucket": "storagebucketname1*****",
                "region": "us-****",
                "defaultAccessLevel": "****"
            }
        }
    }
}''';

@niyonx
Copy link
Author

niyonx commented Dec 13, 2021

Another log:

✓  Built build/app/outputs/flutter-apk/app-debug.apk.
Installing build/app/outputs/flutter-apk/app.apk...
W/FlutterActivityAndFragmentDelegate( 6551): A splash screen was provided to Flutter, but this is deprecated. See flutter.dev/go/android-splash-migration for migration steps.
Debug service listening on ws://127.0.0.1:59456/_AjiCduU0bw=/ws
Syncing files to device sdk gphone x86...
I/amplify:flutter:auth_cognito( 6551): Added Auth plugin
I/AmplifyFlutter( 6551): Added StorageS3 plugin
D/AWSMobileClient( 6551): Using the SignInProviderConfig from `awsconfiguration.json`.
W/AWSMobileClient( 6551): Failed to parse HostedUI settings from store. Defaulting to awsconfiguration.json
W/AWSMobileClient( 6551): java.lang.NullPointerException: Attempt to invoke virtual method 'int java.lang.String.length()' on a null object reference
W/AWSMobileClient( 6551): 	at org.json.JSONTokener.nextCleanInternal(JSONTokener.java:121)
W/AWSMobileClient( 6551): 	at org.json.JSONTokener.nextValue(JSONTokener.java:98)
W/AWSMobileClient( 6551): 	at org.json.JSONObject.<init>(JSONObject.java:165)
W/AWSMobileClient( 6551): 	at org.json.JSONObject.<init>(JSONObject.java:182)
W/AWSMobileClient( 6551): 	at com.amazonaws.mobile.client.AWSMobileClient.getHostedUIJSON(AWSMobileClient.java:713)
W/AWSMobileClient( 6551): 	at com.amazonaws.mobile.client.AWSMobileClient$2.run(AWSMobileClient.java:614)
W/AWSMobileClient( 6551): 	at com.amazonaws.mobile.client.internal.InternalCallback$1.run(InternalCallback.java:101)
W/AWSMobileClient( 6551): 	at java.lang.Thread.run(Thread.java:923)
D/AWSMobileClient( 6551): initialize: Cognito HostedUI client detected
D/AWSMobileClient( 6551): Inspecting user state details
I/ample.pikapoin( 6551): Background young concurrent copying GC freed 11499(1097KB) AllocSpace objects, 8(448KB) LOS objects, 37% free, 2628KB/4206KB, paused 1.392ms total 135.327ms
I/TetheringManager( 6551): registerTetheringEventCallback:com.example.pikapoint
I/flutter ( 6551): In isSignedIn
D/AWSMobileClient( 6551): Inspecting user state details
D/AWSMobileClient( 6551): Inspecting user state details
D/AWSMobileClient( 6551): waitForSignIn: userState:SIGNED_OUT
W/ample.pikapoin( 6551): Verification of void com.google.gson.stream.JsonReader.beginArray() took 167.014ms (359.25 bytecodes/s) (1496B approximate peak alloc)
I/flutter ( 6551): In signInWithSocialWebUI
W/ample.pikapoin( 6551): JNI critical lock held for 16.897ms on Thread[28,tid=6636,Runnable,Thread*=0xe10d5e10,peer=0x12c80000,"Thread-10"]
E/amplify:flutter:auth_cognito( 6551): AuthException
E/amplify:flutter:auth_cognito( 6551): AuthException{message=Sign-in with web UI failed, cause=com.amazonaws.mobileconnectors.cognitoauth.exceptions.BrowserNotInstalledException: No browsers installed., recoverySuggestion=See attached exception for more details}
E/amplify:flutter:auth_cognito( 6551): 	at com.amplifyframework.auth.cognito.AWSCognitoAuthPlugin$22.onError(AWSCognitoAuthPlugin.java:1235)
E/amplify:flutter:auth_cognito( 6551): 	at com.amazonaws.mobile.client.internal.InternalCallback.call(InternalCallback.java:77)
E/amplify:flutter:auth_cognito( 6551): 	at com.amazonaws.mobile.client.internal.InternalCallback.onError(InternalCallback.java:67)
E/amplify:flutter:auth_cognito( 6551): 	at com.amazonaws.mobile.client.AWSMobileClient$26$1$3.run(AWSMobileClient.java:3463)
E/amplify:flutter:auth_cognito( 6551): 	at java.lang.Thread.run(Thread.java:923)
E/amplify:flutter:auth_cognito( 6551): Caused by: com.amazonaws.mobileconnectors.cognitoauth.exceptions.BrowserNotInstalledException: No browsers installed.
E/amplify:flutter:auth_cognito( 6551): 	at com.amazonaws.mobileconnectors.cognitoauth.AuthClient.launchCustomTabs(AuthClient.java:801)
E/amplify:flutter:auth_cognito( 6551): 	at com.amazonaws.mobileconnectors.cognitoauth.AuthClient.launchCognitoAuth(AuthClient.java:712)
E/amplify:flutter:auth_cognito( 6551): 	at com.amazonaws.mobileconnectors.cognitoauth.AuthClient.getSession(AuthClient.java:270)
E/amplify:flutter:auth_cognito( 6551): 	at com.amazonaws.mobileconnectors.cognitoauth.AuthClient.getSession(AuthClient.java:221)
E/amplify:flutter:auth_cognito( 6551): 	at com.amazonaws.mobileconnectors.cognitoauth.Auth.getSession(Auth.java:678)
E/amplify:flutter:auth_cognito( 6551): 	at com.amazonaws.mobile.client.AWSMobileClient$26.run(AWSMobileClient.java:3481)
E/amplify:flutter:auth_cognito( 6551): 	at com.amazonaws.mobile.client.internal.InternalCallback$1.run(InternalCallback.java:101)
E/amplify:flutter:auth_cognito( 6551): 	... 1 more
I/flutter ( 6551): AuthException(message: Sign-in with web UI failed, recoverySuggestion: See attached exception for more details, underlyingException: com.amazonaws.mobileconnectors.cognitoauth.exceptions.BrowserNotInstalledException: No browsers installed.)
I/flutter ( 6551): In signInWithSocialWebUI
E/amplify:flutter:auth_cognito( 6551): AuthException
E/amplify:flutter:auth_cognito( 6551): AuthException{message=Sign-in with web UI failed, cause=com.amazonaws.mobileconnectors.cognitoauth.exceptions.BrowserNotInstalledException: No browsers installed., recoverySuggestion=See attached exception for more details}
E/amplify:flutter:auth_cognito( 6551): 	at com.amplifyframework.auth.cognito.AWSCognitoAuthPlugin$22.onError(AWSCognitoAuthPlugin.java:1235)
E/amplify:flutter:auth_cognito( 6551): 	at com.amazonaws.mobile.client.internal.InternalCallback.call(InternalCallback.java:77)
E/amplify:flutter:auth_cognito( 6551): 	at com.amazonaws.mobile.client.internal.InternalCallback.onError(InternalCallback.java:67)
E/amplify:flutter:auth_cognito( 6551): 	at com.amazonaws.mobile.client.AWSMobileClient$26$1$3.run(AWSMobileClient.java:3463)
E/amplify:flutter:auth_cognito( 6551): 	at java.lang.Thread.run(Thread.java:923)
E/amplify:flutter:auth_cognito( 6551): Caused by: com.amazonaws.mobileconnectors.cognitoauth.exceptions.BrowserNotInstalledException: No browsers installed.
E/amplify:flutter:auth_cognito( 6551): 	at com.amazonaws.mobileconnectors.cognitoauth.AuthClient.launchCustomTabs(AuthClient.java:801)
E/amplify:flutter:auth_cognito( 6551): 	at com.amazonaws.mobileconnectors.cognitoauth.AuthClient.launchCognitoAuth(AuthClient.java:712)
E/amplify:flutter:auth_cognito( 6551): 	at com.amazonaws.mobileconnectors.cognitoauth.AuthClient.getSession(AuthClient.java:270)
E/amplify:flutter:auth_cognito( 6551): 	at com.amazonaws.mobileconnectors.cognitoauth.AuthClient.getSession(AuthClient.java:221)
E/amplify:flutter:auth_cognito( 6551): 	at com.amazonaws.mobileconnectors.cognitoauth.Auth.getSession(Auth.java:678)
E/amplify:flutter:auth_cognito( 6551): 	at com.amazonaws.mobile.client.AWSMobileClient$26.run(AWSMobileClient.java:3481)
E/amplify:flutter:auth_cognito( 6551): 	at com.amazonaws.mobile.client.internal.InternalCallback$1.run(InternalCallback.java:101)
E/amplify:flutter:auth_cognito( 6551): 	... 1 more
I/flutter ( 6551): AuthException(message: Sign-in with web UI failed, recoverySuggestion: See attached exception for more details, underlyingException: com.amazonaws.mobileconnectors.cognitoauth.exceptions.BrowserNotInstalledException: No browsers installed.)

@HuiSF
Copy link
Member

HuiSF commented Dec 14, 2021

Thanks @niyonx .

In what environment you are testing the App? Android emulator, physical Android device? Do you have Chrome installed?
Could you also provide the AndroidManifest.xml file of your App?

@niyonx
Copy link
Author

niyonx commented Dec 14, 2021

I am testing on an android emulator. Yes I have chrome installed.

I actually forgot to modify the AndroidManifest.xml. Now the actual sign in sign up are working, but I still get some errors on the amplify configuration. It is still using config from awsconfiguration.json for some reason.

I/amplify:flutter:auth_cognito( 7573): Added Auth plugin
I/AmplifyFlutter( 7573): Added StorageS3 plugin
D/AWSMobileClient( 7573): Using the SignInProviderConfig from `awsconfiguration.json`.
W/AWSMobileClient( 7573): Failed to parse HostedUI settings from store. Defaulting to awsconfiguration.json
W/AWSMobileClient( 7573): java.lang.NullPointerException: Attempt to invoke virtual method 'int java.lang.String.length()' on a null object reference
W/AWSMobileClient( 7573): 	at org.json.JSONTokener.nextCleanInternal(JSONTokener.java:121)
W/AWSMobileClient( 7573): 	at org.json.JSONTokener.nextValue(JSONTokener.java:98)
W/AWSMobileClient( 7573): 	at org.json.JSONObject.<init>(JSONObject.java:165)
W/AWSMobileClient( 7573): 	at org.json.JSONObject.<init>(JSONObject.java:182)
W/AWSMobileClient( 7573): 	at com.amazonaws.mobile.client.AWSMobileClient.getHostedUIJSON(AWSMobileClient.java:713)
W/AWSMobileClient( 7573): 	at com.amazonaws.mobile.client.AWSMobileClient$2.run(AWSMobileClient.java:614)
W/AWSMobileClient( 7573): 	at com.amazonaws.mobile.client.internal.InternalCallback$1.run(InternalCallback.java:101)
W/AWSMobileClient( 7573): 	at java.lang.Thread.run(Thread.java:923)
D/AWSMobileClient( 7573): initialize: Cognito HostedUI client detected

Here is my manifest

<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="com.example.myapp">
    <queries>
        <intent>
            <action android:name=
                "android.support.customtabs.action.CustomTabsService" />
        </intent>
    </queries>
   <application
        android:label="myapp"
        android:icon="@mipmap/launcher_icon">
        <activity
            android:name=".MainActivity"
            android:launchMode="singleTop"
            android:theme="@style/LaunchTheme"
            android:configChanges="orientation|keyboardHidden|keyboard|screenSize|smallestScreenSize|locale|layoutDirection|fontScale|screenLayout|density|uiMode"
            android:hardwareAccelerated="true"
            android:windowSoftInputMode="adjustResize">
            <!-- Specifies an Android theme to apply to this Activity as soon as
                 the Android process has started. This theme is visible to the user
                 while the Flutter UI initializes. After that, this theme continues
                 to determine the Window background behind the Flutter UI. -->
            <meta-data
              android:name="io.flutter.embedding.android.NormalTheme"
              android:resource="@style/NormalTheme"
              />
            <!-- Displays an Android View that continues showing the launch screen
                 Drawable until Flutter paints its first frame, then this splash
                 screen fades out. A splash screen is useful to avoid any visual
                 gap between the end of Android's launch screen and the painting of
                 Flutter's first frame. -->
            <meta-data
              android:name="io.flutter.embedding.android.SplashScreenDrawable"
              android:resource="@drawable/launch_background"
              />
            <intent-filter>
                <action android:name="android.intent.action.MAIN"/>
                <category android:name="android.intent.category.LAUNCHER"/>
            </intent-filter>
        </activity>
       <activity
           android:name="com.amplifyframework.auth.cognito.activities.HostedUIRedirectActivity">
           <intent-filter>
               <action android:name="android.intent.action.VIEW" />
               <category android:name="android.intent.category.DEFAULT" />
               <category android:name="android.intent.category.BROWSABLE" />
               <data android:scheme="myapp" />
           </intent-filter>
       </activity>
        <!-- Don't delete the meta-data below.
             This is used by the Flutter tool to generate GeneratedPluginRegistrant.java -->
        <meta-data
            android:name="flutterEmbedding"
            android:value="2" />
    </application>
</manifest>

@HuiSF HuiSF changed the title Android cannot have both sign in and social sign in? Android social sign in throws exception of loading awsconfiguration.json Dec 14, 2021
@HuiSF
Copy link
Member

HuiSF commented Dec 14, 2021

Thanks for the follow up @niyonx and I'm glad the social sign in is working.
Will look into the exception thrown about awsconfiguration.json.

@HuiSF HuiSF added the to-be-reproduced Issues that have not been reproduced yet, but have reproduction steps provided label Dec 14, 2021
@HuiSF
Copy link
Member

HuiSF commented Dec 14, 2021

The exception seems caused by this issue aws-amplify/amplify-android#1180 when configuring and using both user name login and social login.

@HuiSF HuiSF added requires-android-fix This issue is the result of an underlying Amplify Android issue that needs to be fixed. and removed to-be-reproduced Issues that have not been reproduced yet, but have reproduction steps provided labels Dec 14, 2021
@Jordan-Nelson Jordan-Nelson changed the title Android social sign in throws exception of loading awsconfiguration.json Support basic sign in and hosted UI sign in in same app Mar 8, 2022
@Jordan-Nelson Jordan-Nelson added feature-request A request for a new feature or an enhancement to an existing API or category. Android Issues specific to the Android Platform labels Mar 8, 2022
@ben-the-developer
Copy link

ben-the-developer commented Aug 17, 2022

Hi everyone, I am experiencing a similar issue by introducing the basic sign in with username/password and social sign in with Google and Facebook to the same app. I am using amplify_flutter 1.0.0-next.0+1, and test it in Android emulator Pixel 4 with API 33.

The error I get is

I/flutter (16849): ERROR | SignInStateMachine | Emitted error: UserNotFoundException {
I/flutter (16849):   message=User does not exist.,
I/flutter (16849): }

When I remove the OAuth section in the awsconfiguration.json, then the username/password sign in can work. But when I add the OAuth section back, then the username/password sign in starts throwing exception.

May I ask if there is any update? Or is there any workaround? Thank you

@dnys1
Copy link
Contributor

dnys1 commented Aug 17, 2022

Hi @ben-the-developer, this use case should be supported in our dev-preview. Would you be willing to create a separate ticket with the methods you're calling and your full configuration file? You mention awsconfiguration.json but this is typically not used for Flutter apps - do you mean amplifyconfiguration.dart? Cheers!

@ben-the-developer
Copy link

Hi @dnys1 , yea, it's amplifyconfiguration.dart. I will start a new ticket to describe my question.

@Jordan-Nelson
Copy link
Member

@niyonx - Were you able to get sign in fully working? If so, I think the logs you are seeing can be safely ignored.

I also wanted to not that we have recently released a new developer preview version of the Auth category (amplify_flutter v1.0.0-next.0). This new version is a full re-write of the auth category in dart. I don't think you will see this issue in this version as it doesn't depend on Amplify-Android.

You can read more about the developer preview release in the blog post and docs.

Let me know if the issue you saw was preventing sign in from functioning or if you were just observing the messages in the logs.

@Jordan-Nelson Jordan-Nelson added pending-triage This issue is in the backlog of issues to triage and removed feature-request A request for a new feature or an enhancement to an existing API or category. labels Aug 23, 2022
@Jordan-Nelson Jordan-Nelson self-assigned this Aug 23, 2022
@Jordan-Nelson Jordan-Nelson added the pending-community-response Pending response from the issue opener or other community members label Aug 23, 2022
@Jordan-Nelson
Copy link
Member

@niyonx - Please let me know if you are still facing an issue. Otherwise I will close this issue out.

@Jordan-Nelson Jordan-Nelson added pending-close-response-required The issue will be closed if details necessary to reproduce the issue are not provided within 7 days. and removed pending-community-response Pending response from the issue opener or other community members requires-android-fix This issue is the result of an underlying Amplify Android issue that needs to be fixed. labels Sep 19, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Android Issues specific to the Android Platform auth Issues related to the Auth Category pending-close-response-required The issue will be closed if details necessary to reproduce the issue are not provided within 7 days. pending-triage This issue is in the backlog of issues to triage
Projects
None yet
Development

No branches or pull requests

6 participants