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

Cannot authenticate: Auth.signIn() fails with "false provider" and "Error in federating the token" messages in Android simulator #1204

Closed
dorontal opened this issue Dec 12, 2021 · 27 comments
Labels
auth Issues related to the Auth Category to-be-reproduced Issues that have not been reproduced yet, but have reproduction steps provided

Comments

@dorontal
Copy link

dorontal commented Dec 12, 2021

Describe the bug
The Auth flow for this app is email & password sign-in / sign-up, with email only verification. When calling await Amplify.Auth.signIn(...) from an app running on the Android simulator, the user never gets signed in! Instead, you see some Java errors in the debug console (they are pasted below) and even though the call to signIn() returns an object with .isSignedIn == true and .nextStep!.signInStep == 'DONE' the user never gets to be signed in -- that's at least true in the following sense: if you call await getCurrentUser() right after the await signIn() call it throws a SignedOutException; if you call await Auth.fetchAuthSession() it returns a session whose .isSignedIn is false and if you call await Auth.fetchAuthSession(options: CognitoSessionOptions(getAWSCredentials: true)) it throws a SessionExpiredException as described in issue #441.

[ This happens after an email-only signUp() call with email-verification, made via the call

  await Amplify.Auth.signUp(username: email, password: password);

]

I checked that amplifyconfiguration.dart has been created correctly and that the relevant values for endpoints of the user pool and identity pool and identity-pool Id there match those on the AWS console - they all do. Here is the output of the Android simulator when running right after the call to Amplify.Auth.signIn():

D/AWSMobileClient(13077): _federatedSignIn: Putting provider and token in store
D/AWSMobileClient(13077): Inspecting user state details
D/AWSMobileClient(13077): hasFederatedToken: false provider: cognito-idp.us-east-1.amazonaws.com/us-east-1_xxxxxxxxx
W/AWSMobileClient(13077): Failed to federate tokens during sign-in
W/AWSMobileClient(13077): java.lang.RuntimeException: Error in federating the token.
W/AWSMobileClient(13077): 	at com.amazonaws.mobile.client.AWSMobileClient$10.run(AWSMobileClient.java:1826)
W/AWSMobileClient(13077): 	at com.amazonaws.mobile.client.internal.InternalCallback.await(InternalCallback.java:115)
W/AWSMobileClient(13077): 	at com.amazonaws.mobile.client.AWSMobileClient.federatedSignInWithoutAssigningState(AWSMobileClient.java:1754)
W/AWSMobileClient(13077): 	at com.amazonaws.mobile.client.AWSMobileClient$6$1.onSuccess(AWSMobileClient.java:1243)
W/AWSMobileClient(13077): 	at com.amazonaws.mobileconnectors.cognitoidentityprovider.CognitoUser.getSession(CognitoUser.java:1023)
W/AWSMobileClient(13077): 	at com.amazonaws.mobile.client.AWSMobileClient$6.run(AWSMobileClient.java:1228)
W/AWSMobileClient(13077): 	at com.amazonaws.mobile.client.internal.InternalCallback$1.run(InternalCallback.java:101)
W/AWSMobileClient(13077): 	at java.lang.Thread.run(Thread.java:764)
W/AWSMobileClient(13077): 	at com.amazonaws.auth.CognitoCachingCredentialsProvider.refresh(CognitoCachingCredentialsProvider.java:511)
W/AWSMobileClient(13077): 	at com.amazonaws.auth.CognitoCachingCredentialsProvider.getIdentityId(CognitoCachingCredentialsProvider.java:453)
W/AWSMobileClient(13077): 	at com.amazonaws.auth.CognitoCredentialsProvider.populateCredentialsWithCognito(CognitoCredentialsProvider.java:785)
W/AWSMobileClient(13077): 	at com.amazonaws.auth.CognitoCredentialsProvider.startSession(CognitoCredentialsProvider.java:703)
W/AWSMobileClient(13077): 	at com.amazonaws.auth.CognitoCredentialsProvider.refresh(CognitoCredentialsProvider.java:640)
W/AWSMobileClient(13077): 	at com.amazonaws.auth.CognitoCachingCredentialsProvider.refresh(CognitoCachingCredentialsProvider.java:511)
W/AWSMobileClient(13077): 	at com.amazonaws.mobile.client.AWSMobileClient.federateWithCognitoIdentity(AWSMobileClient.java:1857)
W/AWSMobileClient(13077): 	at com.amazonaws.mobile.client.AWSMobileClient$10.run(AWSMobileClient.java:1813)
W/AWSMobileClient(13077): 	... 7 more

NOTE: This bug is showing up in code that used to work - the same code did not produce the bug in the past. Either something is wrong with the network infrastructure or perhaps it is related to an older version of the Amplify Flutter library - not sure, but the code definitely worked before with an older version of the Amplify Flutter libraries.

A clear and concise description of what the bug is.

To Reproduce
Steps to reproduce the behavior:

  1. Set up an Amplify Auth via Cognito user pools for email + password login and for email-only verification, via
      await Amplify.Auth.signUp(username: email, password: password);
  2. sign in with email & password via
      await Amplify.Auth.signIn(email: email, password: password)
  3. call await Amplify.Auth.getCurrentUser() immediately after that and it will throw a SignedOutException also you'll see the above output in your debug console

Expected behavior
Expected getCurrentUser() to return a user object that allows us to get the sub and the email for that user.

Platform
Amplify Flutter current supports iOS and Android. This issue is reproducible in (check all that apply):
Only tested in Android simulator.

Output of flutter doctor -v
[✓] Flutter (Channel stable, 2.8.0, on Debian GNU/Linux 10 (buster) 4.19.0-18-amd64, locale en_US.UTF-8)
  • Flutter version 2.8.0 at /usr/local/src/flutter/flutter
  • Upstream repository https://github.com/flutter/flutter.git
  • Framework revision cf44000065 (3 days ago), 2021-12-08 14:06:50 -0800
  • Engine revision 40a99c5951
  • Dart version 2.15.0

[✓] Android toolchain - develop for Android devices (Android SDK version 31.0.0)
  • Android SDK at /home/dtal/Android/Sdk
  • Platform android-31, build-tools 31.0.0
  • Java binary at: /usr/local/src/android-studio/android-studio/jre/bin/java
  • Java version OpenJDK Runtime Environment (build 11.0.10+0-b96-7249189)
  • All Android licenses accepted.

[✓] Chrome - develop for the web
  • Chrome at google-chrome

[✓] Linux toolchain - develop for Linux desktop
  • clang version 7.0.1-8+deb10u2 (tags/RELEASE_701/final)
  • cmake version 3.13.4
  • ninja version 1.8.2
  • pkg-config version 0.29

[✓] Android Studio (version 2020.3)
  • Android Studio at /usr/local/src/android-studio/android-studio
  • Flutter plugin version 62.0.1
  • Dart plugin version 203.8452
  • Java version OpenJDK Runtime Environment (build 11.0.10+0-b96-7249189)

[✓] VS Code (version 1.63.0)
  • VS Code at /usr/share/code
  • Flutter extension version 3.29.0

[✓] Connected device (3 available)
  • Android SDK built for x86 (mobile) • emulator-5554 • android-x86    • Android 8.0.0 (API 26) (emulator)
  • Linux (desktop)                    • linux         • linux-x64      • Debian GNU/Linux 10 (buster) 4.19.0-18-amd64
  • Chrome (web)                       • chrome        • web-javascript • Google Chrome 96.0.4664.93

• No issues found!
Dependencies (pubspec.lock)
Paste the contents of your "pubspec.lock" file here


# Generated by pub
# See https://dart.dev/tools/pub/glossary#lockfile
packages:
_fe_analyzer_shared:
  dependency: transitive
  description:
    name: _fe_analyzer_shared
    url: "https://pub.dartlang.org"
  source: hosted
  version: "31.0.0"
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:
  dependency: "direct main"
  description:
    name: amplify_api
    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"
analyzer:
  dependency: transitive
  description:
    name: analyzer
    url: "https://pub.dartlang.org"
  source: hosted
  version: "2.8.0"
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.2"
boolean_selector:
  dependency: transitive
  description:
    name: boolean_selector
    url: "https://pub.dartlang.org"
  source: hosted
  version: "2.1.0"
build:
  dependency: transitive
  description:
    name: build
    url: "https://pub.dartlang.org"
  source: hosted
  version: "2.1.1"
build_config:
  dependency: transitive
  description:
    name: build_config
    url: "https://pub.dartlang.org"
  source: hosted
  version: "1.0.0"
build_daemon:
  dependency: transitive
  description:
    name: build_daemon
    url: "https://pub.dartlang.org"
  source: hosted
  version: "3.0.1"
build_resolvers:
  dependency: transitive
  description:
    name: build_resolvers
    url: "https://pub.dartlang.org"
  source: hosted
  version: "2.0.5"
build_runner:
  dependency: "direct dev"
  description:
    name: build_runner
    url: "https://pub.dartlang.org"
  source: hosted
  version: "2.1.5"
build_runner_core:
  dependency: transitive
  description:
    name: build_runner_core
    url: "https://pub.dartlang.org"
  source: hosted
  version: "7.2.2"
built_collection:
  dependency: transitive
  description:
    name: built_collection
    url: "https://pub.dartlang.org"
  source: hosted
  version: "5.1.1"
built_value:
  dependency: transitive
  description:
    name: built_value
    url: "https://pub.dartlang.org"
  source: hosted
  version: "8.1.3"
characters:
  dependency: transitive
  description:
    name: characters
    url: "https://pub.dartlang.org"
  source: hosted
  version: "1.2.0"
charcode:
  dependency: transitive
  description:
    name: charcode
    url: "https://pub.dartlang.org"
  source: hosted
  version: "1.3.1"
checked_yaml:
  dependency: transitive
  description:
    name: checked_yaml
    url: "https://pub.dartlang.org"
  source: hosted
  version: "2.0.1"
cli_util:
  dependency: transitive
  description:
    name: cli_util
    url: "https://pub.dartlang.org"
  source: hosted
  version: "0.3.5"
clock:
  dependency: transitive
  description:
    name: clock
    url: "https://pub.dartlang.org"
  source: hosted
  version: "1.1.0"
code_builder:
  dependency: transitive
  description:
    name: code_builder
    url: "https://pub.dartlang.org"
  source: hosted
  version: "4.1.0"
collection:
  dependency: transitive
  description:
    name: collection
    url: "https://pub.dartlang.org"
  source: hosted
  version: "1.15.0"
convert:
  dependency: transitive
  description:
    name: convert
    url: "https://pub.dartlang.org"
  source: hosted
  version: "3.0.1"
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"
dart_style:
  dependency: transitive
  description:
    name: dart_style
    url: "https://pub.dartlang.org"
  source: hosted
  version: "2.2.0"
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"
file:
  dependency: transitive
  description:
    name: file
    url: "https://pub.dartlang.org"
  source: hosted
  version: "6.1.2"
fixnum:
  dependency: transitive
  description:
    name: fixnum
    url: "https://pub.dartlang.org"
  source: hosted
  version: "1.0.0"
flutter:
  dependency: "direct main"
  description: flutter
  source: sdk
  version: "0.0.0"
flutter_hooks:
  dependency: "direct main"
  description:
    name: flutter_hooks
    url: "https://pub.dartlang.org"
  source: hosted
  version: "0.18.1"
flutter_lints:
  dependency: "direct dev"
  description:
    name: flutter_lints
    url: "https://pub.dartlang.org"
  source: hosted
  version: "1.0.4"
flutter_riverpod:
  dependency: transitive
  description:
    name: flutter_riverpod
    url: "https://pub.dartlang.org"
  source: hosted
  version: "1.0.2"
flutter_test:
  dependency: "direct dev"
  description: flutter
  source: sdk
  version: "0.0.0"
frontend_server_client:
  dependency: transitive
  description:
    name: frontend_server_client
    url: "https://pub.dartlang.org"
  source: hosted
  version: "2.1.2"
glob:
  dependency: transitive
  description:
    name: glob
    url: "https://pub.dartlang.org"
  source: hosted
  version: "2.0.2"
google_fonts:
  dependency: "direct main"
  description:
    name: google_fonts
    url: "https://pub.dartlang.org"
  source: hosted
  version: "2.1.0"
graphs:
  dependency: transitive
  description:
    name: graphs
    url: "https://pub.dartlang.org"
  source: hosted
  version: "2.1.0"
hooks_riverpod:
  dependency: "direct main"
  description:
    name: hooks_riverpod
    url: "https://pub.dartlang.org"
  source: hosted
  version: "1.0.2"
http:
  dependency: transitive
  description:
    name: http
    url: "https://pub.dartlang.org"
  source: hosted
  version: "0.13.4"
http_multi_server:
  dependency: transitive
  description:
    name: http_multi_server
    url: "https://pub.dartlang.org"
  source: hosted
  version: "3.0.1"
http_parser:
  dependency: transitive
  description:
    name: http_parser
    url: "https://pub.dartlang.org"
  source: hosted
  version: "4.0.0"
io:
  dependency: transitive
  description:
    name: io
    url: "https://pub.dartlang.org"
  source: hosted
  version: "1.0.3"
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"
logging:
  dependency: transitive
  description:
    name: logging
    url: "https://pub.dartlang.org"
  source: hosted
  version: "1.0.2"
matcher:
  dependency: transitive
  description:
    name: matcher
    url: "https://pub.dartlang.org"
  source: hosted
  version: "0.12.11"
meta:
  dependency: transitive
  description:
    name: meta
    url: "https://pub.dartlang.org"
  source: hosted
  version: "1.7.0"
mime:
  dependency: transitive
  description:
    name: mime
    url: "https://pub.dartlang.org"
  source: hosted
  version: "1.0.1"
mockito:
  dependency: "direct dev"
  description:
    name: mockito
    url: "https://pub.dartlang.org"
  source: hosted
  version: "5.0.16"
network_image_mock:
  dependency: "direct dev"
  description:
    name: network_image_mock
    url: "https://pub.dartlang.org"
  source: hosted
  version: "2.0.1"
package_config:
  dependency: transitive
  description:
    name: package_config
    url: "https://pub.dartlang.org"
  source: hosted
  version: "2.0.2"
path:
  dependency: transitive
  description:
    name: path
    url: "https://pub.dartlang.org"
  source: hosted
  version: "1.8.0"
path_provider:
  dependency: transitive
  description:
    name: path_provider
    url: "https://pub.dartlang.org"
  source: hosted
  version: "2.0.8"
path_provider_android:
  dependency: transitive
  description:
    name: path_provider_android
    url: "https://pub.dartlang.org"
  source: hosted
  version: "2.0.9"
path_provider_ios:
  dependency: transitive
  description:
    name: path_provider_ios
    url: "https://pub.dartlang.org"
  source: hosted
  version: "2.0.7"
path_provider_linux:
  dependency: transitive
  description:
    name: path_provider_linux
    url: "https://pub.dartlang.org"
  source: hosted
  version: "2.1.4"
path_provider_macos:
  dependency: transitive
  description:
    name: path_provider_macos
    url: "https://pub.dartlang.org"
  source: hosted
  version: "2.0.4"
path_provider_platform_interface:
  dependency: transitive
  description:
    name: path_provider_platform_interface
    url: "https://pub.dartlang.org"
  source: hosted
  version: "2.0.1"
path_provider_windows:
  dependency: transitive
  description:
    name: path_provider_windows
    url: "https://pub.dartlang.org"
  source: hosted
  version: "2.0.4"
platform:
  dependency: transitive
  description:
    name: platform
    url: "https://pub.dartlang.org"
  source: hosted
  version: "3.1.0"
plugin_platform_interface:
  dependency: transitive
  description:
    name: plugin_platform_interface
    url: "https://pub.dartlang.org"
  source: hosted
  version: "2.0.2"
pool:
  dependency: transitive
  description:
    name: pool
    url: "https://pub.dartlang.org"
  source: hosted
  version: "1.5.0"
process:
  dependency: transitive
  description:
    name: process
    url: "https://pub.dartlang.org"
  source: hosted
  version: "4.2.4"
pub_semver:
  dependency: transitive
  description:
    name: pub_semver
    url: "https://pub.dartlang.org"
  source: hosted
  version: "2.1.0"
pubspec_parse:
  dependency: transitive
  description:
    name: pubspec_parse
    url: "https://pub.dartlang.org"
  source: hosted
  version: "1.2.0"
riverpod:
  dependency: transitive
  description:
    name: riverpod
    url: "https://pub.dartlang.org"
  source: hosted
  version: "1.0.2"
shelf:
  dependency: transitive
  description:
    name: shelf
    url: "https://pub.dartlang.org"
  source: hosted
  version: "1.2.0"
shelf_web_socket:
  dependency: transitive
  description:
    name: shelf_web_socket
    url: "https://pub.dartlang.org"
  source: hosted
  version: "1.0.1"
sky_engine:
  dependency: transitive
  description: flutter
  source: sdk
  version: "0.0.99"
source_gen:
  dependency: transitive
  description:
    name: source_gen
    url: "https://pub.dartlang.org"
  source: hosted
  version: "1.2.0"
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"
state_notifier:
  dependency: transitive
  description:
    name: state_notifier
    url: "https://pub.dartlang.org"
  source: hosted
  version: "0.7.1"
stream_channel:
  dependency: transitive
  description:
    name: stream_channel
    url: "https://pub.dartlang.org"
  source: hosted
  version: "2.1.0"
stream_transform:
  dependency: transitive
  description:
    name: stream_transform
    url: "https://pub.dartlang.org"
  source: hosted
  version: "2.0.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.3"
timing:
  dependency: transitive
  description:
    name: timing
    url: "https://pub.dartlang.org"
  source: hosted
  version: "1.0.0"
typed_data:
  dependency: transitive
  description:
    name: typed_data
    url: "https://pub.dartlang.org"
  source: hosted
  version: "1.3.0"
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.1"
watcher:
  dependency: transitive
  description:
    name: watcher
    url: "https://pub.dartlang.org"
  source: hosted
  version: "1.0.1"
web_socket_channel:
  dependency: transitive
  description:
    name: web_socket_channel
    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"
xdg_directories:
  dependency: transitive
  description:
    name: xdg_directories
    url: "https://pub.dartlang.org"
  source: hosted
  version: "0.2.0"
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.5.0"

Smartphone (please complete the following information):

  • Android Simulator only - Android v8.0.0

Additional context
This problem did not exist before - I believe it was the same code but an older version of the Amplify libraries.

@dorontal dorontal changed the title Android simulator client Amplify.Auth.signIn() fails with "Error in federating the token" Android simulator client Amplify.Auth.signIn() fails with "false provider" and "Error in federating the token" error messages Dec 12, 2021
@dorontal dorontal changed the title Android simulator client Amplify.Auth.signIn() fails with "false provider" and "Error in federating the token" error messages Cannot authenticate: Auth.signIn() fails with "false provider" and "Error in federating the token" error messages in Android device simulations Dec 12, 2021
@dorontal dorontal changed the title Cannot authenticate: Auth.signIn() fails with "false provider" and "Error in federating the token" error messages in Android device simulations Cannot authenticate: Auth.signIn() fails with "false provider" and "Error in federating the token" messages in Android simulator Dec 12, 2021
@Jordan-Nelson
Copy link
Member

Hello @dorontal - Thanks for opening the issue. I want to clarify a few things.

Are you awaiting the future returned from Auth.signIn(). Do the calls look like:

Amplify.Auth.signIn()
Amplify.Auth.getCurrentUser()

or this:

await Amplify.Auth.signIn()
Amplify.Auth.getCurrentUser()

Do you know what version of amplify_flutter you were using when this was working?

Do you know if you were using the same device and OS version when this was working?

Thanks

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

@Jordan-Nelson --

Are you awaiting the future returned from Auth.signIn()?

Yes. awaiting both calls: the one to Amplify.Auth.signIn() and the one to Amplify.Auth.getCurrentUser()

Do you know what version of amplify_flutter you were using when this was working?

Please accept my apologies but I do not know which version worked. I know that when I saw things working:

  • I saw them working briefly - this issue has been around for me for at least one week and possibly longer and it may have existed with previous versions
  • I have a bunch of scripts that recreate the entire amplify environment from scratch and have been using those every time ther's a new version of the Amplify CLI, to upgrade to the new version right away, usually on the same day of the release
  • When I saw things working briefly - roughly a week or two ago - I saw the following behaviors:
    • when a user logs in, then logs out, then you kill the app completely and restart it in the emulator, upon restart the user gets automatically signed-in again, i.e. the Amplify library seems to have kept the token persisted somewhere and it will reload that token if the session has not yet expired, automatically
    • when a user sings in, the awaited call to getCurrentUser(), which happens immediately after the awaited call to Auth.signIn() did return a user and did not throw an exception - ie. the user did get signed-in

Do you know if you were using the same device and OS version when this was working?

Always used the same device & OS - they have always been the Android Simulator from Android Studio. The emulated device is a mobile "Nexus 6" like device with Android 8.0 x86 "Oreo"

@Jordan-Nelson
Copy link
Member

@dorontal - Thanks for the info.

I have a bunch of scripts that recreate the entire amplify environment from scratch and have been using those every time ther's a new version of the Amplify CLI, to upgrade to the new version right away, usually on the same day of the release

It sounds like you are frequently recreating environments with the latest CLI version. Your pubspec file shows you are using amplify_flutter 0.2.10. Do you also frequently upgrade this, or do you believe you were using the same version of amplify_flutter when this was previously working?

@dorontal
Copy link
Author

Thanks @Jordan-Nelson for responding. Unfortunately, I don't remember exactly. Looking through the backups for this project, which only start on 12/5, I see that on 12/10 I switched over from Amplify CLI version 7.6.2 to 7.6.3. It's quite possible but not certain that the switch to 7.6.3 sparked this issue.

@Jordan-Nelson
Copy link
Member

The version of amplify_flutter and amplify cli are not connected. Even though you are frequently upgrading amplify cli, you may have been using the same version of amplify_flutter. This is not necessarily an issue, but it would be helpful to know if you are also frequently upgrading amplify_flutter in order to reproduce this.

The amplify_flutter version is specified in your pubspec.yaml file. Based on the output from your pubspec.lock, you are currently using version 0.2.10 of amplify_flutter. Do you know if you have upgraded the version of amplify_flutter (the value listed in your your pubspec.yaml file, not the cli version) recently?

@dorontal
Copy link
Author

dorontal commented Dec 13, 2021

@Jordan-Nelson just checked the repository history of pubspec.yaml and it appears that as far as the library goes I've been using 0.2.10 since 14 days ago. This means, most likely, that when I saw things working, they were working with version 0.2.10, not due to some previous upgrade of the library that I had installed. Not 100% sure. Then things stopped working with the same version 0.2.10 - thus this issue.

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

Today, with absolutely zero new changes to the code since this issue was reported - everything is working! The user does get signed in after the call to Auth.signIn() and the immediate call to getCurrentUser() after that indeed returns the correct instance of AuthUser.

I'm going to assume that this was an infrastructure issue on the AWS server end and close this.

@dorontal
Copy link
Author

dorontal commented Dec 18, 2021

Today, after upgrading to the Amplify CLI version 7.6.4 and re-deploying re-scaffolding the entire Amplify environment and folder from scratch exactly the same way it was before (via automatic shell and expect scripts), this issue came right back as described above, so re-opening it.

I don't know what is causing this issue to be intermittent. Does anybody see a similar issue? To summarize, what I see is that after a call to Auth.signIn() the user does not get signed in (even though the result of the signIn() call does say the user got signed in). Calling Auth.getCurrentUser() right after Auth.signIn() throws a SignedOutException. This is happening with an auth flow that involves signing up with email & password, with email-verified code - this sign-up process did seem to work as expected.

@dorontal dorontal reopened this Dec 18, 2021
@dorontal
Copy link
Author

dorontal commented Dec 18, 2021

Noticed that there are more error messages not shown above, so here's the output, in VSCode's "DEBUG CONSOLE" tab:

I'll split this output into phases, depending on which function is getting called per phase:

Upon starting the app, before the auth service is even activated, we see this:

D/AWSMobileClient( 5461): Using the SignInProviderConfig from `awsconfiguration.json`.
D/EGL_emulation( 5461): eglMakeCurrent: 0xa350bb20: ver 3 1 (tinfo 0x8ef671a0)
I/zygote  ( 5461): Do partial code cache collection, code=61KB, data=48KB
I/zygote  ( 5461): After code cache collection, code=57KB, data=47KB
I/zygote  ( 5461): Increasing code cache capacity to 256KB
D/AWSMobileClient( 5461): Inspecting user state details
D/NetworkSecurityConfig( 5461): No Network Security Config specified, using platform default

The app calls Auth.getCurrentUser() initially, to see if there's already a user signed in (via persisted token) and to start its user stream. That call throws a SignedOutException:

E/amplify:flutter:auth_cognito( 5461): SignedOutException
E/amplify:flutter:auth_cognito( 5461): SignedOutException{message=You are currently signed out., cause=null, recoverySuggestion=Please sign in and reattempt the operation.}
E/amplify:flutter:auth_cognito( 5461): 	at com.amazonaws.amplify.amplify_auth_cognito.AuthCognito.onGetCurrentUser(AuthCognito.kt:408)
E/amplify:flutter:auth_cognito( 5461): 	at com.amazonaws.amplify.amplify_auth_cognito.AuthCognito.onMethodCall(AuthCognito.kt:199)
E/amplify:flutter:auth_cognito( 5461): 	at io.flutter.plugin.common.MethodChannel$IncomingMethodCallHandler.onMessage(MethodChannel.java:262)
E/amplify:flutter:auth_cognito( 5461): 	at io.flutter.embedding.engine.dart.DartMessenger.invokeHandler(DartMessenger.java:178)
E/amplify:flutter:auth_cognito( 5461): 	at io.flutter.embedding.engine.dart.DartMessenger.lambda$handleMessageFromDart$0$DartMessenger(DartMessenger.java:206)
E/amplify:flutter:auth_cognito( 5461): 	at io.flutter.embedding.engine.dart.-$$Lambda$DartMessenger$6ZD1MYkhaLxyPjtoFDxe45u43DI.run(Unknown Source:12)
E/amplify:flutter:auth_cognito( 5461): 	at android.os.Handler.handleCallback(Handler.java:789)
E/amplify:flutter:auth_cognito( 5461): 	at android.os.Handler.dispatchMessage(Handler.java:98)
E/amplify:flutter:auth_cognito( 5461): 	at android.os.Looper.loop(Looper.java:164)
E/amplify:flutter:auth_cognito( 5461): 	at android.app.ActivityThread.main(ActivityThread.java:6541)
E/amplify:flutter:auth_cognito( 5461): 	at java.lang.reflect.Method.invoke(Native Method)
E/amplify:flutter:auth_cognito( 5461): 	at com.android.internal.os.Zygote$MethodAndArgsCaller.run(Zygote.java:240)
E/amplify:flutter:auth_cognito( 5461): 	at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:767)
[log] *********** getCurrentUser() - signed out

Now a user tries to sign in and Auth.signIn() is called. Here is are the log messages right after that:

D/AWSMobileClient( 5461): _federatedSignIn: Putting provider and token in store
W/AWSMobileClient( 5461): Failed to federate tokens during sign-in
W/AWSMobileClient( 5461): java.lang.RuntimeException: Error in federating the token.
W/AWSMobileClient( 5461): 	at com.amazonaws.mobile.client.AWSMobileClient$10.run(AWSMobileClient.java:1826)
W/AWSMobileClient( 5461): 	at com.amazonaws.mobile.client.internal.InternalCallback.await(InternalCallback.java:115)
W/AWSMobileClient( 5461): 	at com.amazonaws.mobile.client.AWSMobileClient.federatedSignInWithoutAssigningState(AWSMobileClient.java:1754)
W/AWSMobileClient( 5461): 	at com.amazonaws.mobile.client.AWSMobileClient$6$1.onSuccess(AWSMobileClient.java:1243)
W/AWSMobileClient( 5461): 	at com.amazonaws.mobileconnectors.cognitoidentityprovider.CognitoUser.getSession(CognitoUser.java:1023)
W/AWSMobileClient( 5461): 	at com.amazonaws.mobile.client.AWSMobileClient$6.run(AWSMobileClient.java:1228)
W/AWSMobileClient( 5461): 	at com.amazonaws.mobile.client.internal.InternalCallback$1.run(InternalCallback.java:101)
W/AWSMobileClient( 5461): 	at java.lang.Thread.run(Thread.java:764)
W/AWSMobileClient( 5461): Caused by: com.amazonaws.services.cognitoidentity.model.InvalidIdentityPoolConfigurationException: Invalid identity pool configuration. Check assigned IAM roles for this pool. (Service: AmazonCognitoIdentity; Status Code: 400; Error Code: InvalidIdentityPoolConfigurationException; Request ID: 6df9f35f-7d3e-417f-af72-24017265e272)
W/AWSMobileClient( 5461): 	at com.amazonaws.http.AmazonHttpClient.handleErrorResponse(AmazonHttpClient.java:742)
W/AWSMobileClient( 5461): 	at com.amazonaws.http.AmazonHttpClient.executeHelper(AmazonHttpClient.java:420)
W/AWSMobileClient( 5461): 	at com.amazonaws.http.AmazonHttpClient.execute(AmazonHttpClient.java:229)
W/AWSMobileClient( 5461): 	at com.amazonaws.services.cognitoidentity.AmazonCognitoIdentityClient.invoke(AmazonCognitoIdentityClient.java:1836)
W/AWSMobileClient( 5461): 	at com.amazonaws.services.cognitoidentity.AmazonCognitoIdentityClient.getCredentialsForIdentity(AmazonCognitoIdentityClient.java:750)
W/AWSMobileClient( 5461): 	at com.amazonaws.auth.CognitoCredentialsProvider.populateCredentialsWithCognito(CognitoCredentialsProvider.java:791)
W/AWSMobileClient( 5461): 	at com.amazonaws.auth.CognitoCredentialsProvider.startSession(CognitoCredentialsProvider.java:703)
W/AWSMobileClient( 5461): 	at com.amazonaws.auth.CognitoCredentialsProvider.refresh(CognitoCredentialsProvider.java:640)
W/AWSMobileClient( 5461): 	at com.amazonaws.auth.CognitoCachingCredentialsProvider.refresh(CognitoCachingCredentialsProvider.java:511)
W/AWSMobileClient( 5461): 	at com.amazonaws.auth.CognitoCachingCredentialsProvider.getIdentityId(CognitoCachingCredentialsProvider.java:453)
W/AWSMobileClient( 5461): 	at com.amazonaws.auth.CognitoCredentialsProvider.populateCredentialsWithCognito(CognitoCredentialsProvider.java:785)
W/AWSMobileClient( 5461): 	at com.amazonaws.auth.CognitoCredentialsProvider.startSession(CognitoCredentialsProvider.java:703)
W/AWSMobileClient( 5461): 	at com.amazonaws.auth.CognitoCredentialsProvider.refresh(CognitoCredentialsProvider.java:640)
W/AWSMobileClient( 5461): 	at com.amazonaws.auth.CognitoCachingCredentialsProvider.refresh(CognitoCachingCredentialsProvider.java:511)
W/AWSMobileClient( 5461): 	at com.amazonaws.mobile.client.AWSMobileClient.federateWithCognitoIdentity(AWSMobileClient.java:1857)
W/AWSMobileClient( 5461): 	at com.amazonaws.mobile.client.AWSMobileClient$10.run(AWSMobileClient.java:1813)
W/AWSMobileClient( 5461): 	... 7 more
W/InternalCallback( 5461): Library attempted to call user callback twice, expected only once

Notice the message Invalid identity pool configuration. Check assigned IAM roles for this pool above.

I did check the identity pool and user pool connection and configuration in the AWS console and all seems correctly configured there. For example, I used these instructions to check that trust relationships have been properly set-up, plus many other checks -- all seems fine at the AWS console.

Also notice the last message Library attempted to call user callback twice, expected only once.

Right after the call to await Auth.signIn(), we call getCurrentUser() again - this is just debugging code; that call again throws a SignedOutException - but we expected a user now, not an exception!

E/amplify:flutter:auth_cognito( 5461): SignedOutException
E/amplify:flutter:auth_cognito( 5461): SignedOutException{message=You are currently signed out., cause=null, recoverySuggestion=Please sign in and reattempt the operation.}
E/amplify:flutter:auth_cognito( 5461): 	at com.amazonaws.amplify.amplify_auth_cognito.AuthCognito.onGetCurrentUser(AuthCognito.kt:408)
E/amplify:flutter:auth_cognito( 5461): 	at com.amazonaws.amplify.amplify_auth_cognito.AuthCognito.onMethodCall(AuthCognito.kt:199)
E/amplify:flutter:auth_cognito( 5461): 	at io.flutter.plugin.common.MethodChannel$IncomingMethodCallHandler.onMessage(MethodChannel.java:262)
E/amplify:flutter:auth_cognito( 5461): 	at io.flutter.embedding.engine.dart.DartMessenger.invokeHandler(DartMessenger.java:178)
E/amplify:flutter:auth_cognito( 5461): 	at io.flutter.embedding.engine.dart.DartMessenger.lambda$handleMessageFromDart$0$DartMessenger(DartMessenger.java:206)
E/amplify:flutter:auth_cognito( 5461): 	at io.flutter.embedding.engine.dart.-$$Lambda$DartMessenger$6ZD1MYkhaLxyPjtoFDxe45u43DI.run(Unknown Source:12)
E/amplify:flutter:auth_cognito( 5461): 	at android.os.Handler.handleCallback(Handler.java:789)
E/amplify:flutter:auth_cognito( 5461): 	at android.os.Handler.dispatchMessage(Handler.java:98)
E/amplify:flutter:auth_cognito( 5461): 	at android.os.Looper.loop(Looper.java:164)
E/amplify:flutter:auth_cognito( 5461): 	at android.app.ActivityThread.main(ActivityThread.java:6541)
E/amplify:flutter:auth_cognito( 5461): 	at java.lang.reflect.Method.invoke(Native Method)
E/amplify:flutter:auth_cognito( 5461): 	at com.android.internal.os.Zygote$MethodAndArgsCaller.run(Zygote.java:240)
E/amplify:flutter:auth_cognito( 5461): 	at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:767)
[log] *********** getCurrentUser() - signed out
W/InternalCallback( 5461): Library attempted to call user callback twice, expected only once

@Sunsiha
Copy link

Sunsiha commented Dec 20, 2021

any solutions?

@dorontal
Copy link
Author

Just tried again with version 7.6.5 of the Amplify CLI and the same problem remains - cannot sign in a user to the app - a user that had been set up for email & password sign-in with email-verification. All the other parts of the flow: sign-up & code verification worked as expected but sign-in does not work, as reported above.

@dorontal
Copy link
Author

dorontal commented Jan 3, 2022

Still, nobody can sign-in to any of my apps because of this bug. My apps are set-up for email-only verification and sign-up / sign-in. Has anybody been able to log their users into their app when setting up with the CLI version 7.6.5 and Amplify library version 0.2.10 - or do you see this issue as well? It would help to know if anybody has reproduced this, thanks!

@dorontal
Copy link
Author

Just tried the new CLI version 7.6.9 - same problem: this issue still stands exactly as originally reported. It is not possible to sign in users to the app when using email-only sign-up / sign-in. any help would be greatly appreciated!

@fjnoyp
Copy link
Contributor

fjnoyp commented Jan 17, 2022

Hi @dorontal thanks for posting all that information.

It sounds like updating the 'amplify-cli' broke your working setup correct?

Is it easy for you to share the commands you made in amplify cli to setup your project?

I'm thinking that we should make a basic replication of your Auth code flow on our side in Flutter and on an Android native app with Amplify Android. If the problem persists on Android native the issue is likely outside of our Amplify Flutter library which means we should reach out to other teams.

@dorontal
Copy link
Author

Hi @fjnoyp and thanks very much for the response.

Hopefully the issue I reported is not specific/unique to my setup. Not worthwhile for you to replicate the entire setup (8 expect scripts,1 shell script, driven by a master shell script - that create auth, storage, a graphql api, two lambda triggers, a lambda with a rest api) but the most relevant script is the expect script that sets up auth via amplify auth update here it is below. To fully replicate the issue, one needs to use this setup and - from your flutter program - first sign up with email and password, then try to sign in with email and password - you'll see the issue and never be able to sign in in a way that returns success from getCurrentUser(). If you want my code that does the signing in part, I can share that too (the Flutter service that calls signUp/in), but I guess you'll use your own library code for that if anybody replicates it.

Expect script that sets up Auth via amplify auth update for where I saw this issue:

#!/usr/bin/expect -f

set timeout -1

spawn amplify auth update

expect "What do you want to do?"
# Walkthrough all the auth configurations
send -- "�\[B"
send -- "\r"
expect "User Sign-Up, Sign-In, connected with AWS IAM controls"
send -- "\r"
expect "Allow unauthenticated logins?"
# Yes
send -- "�\[A"
send -- "\r"
expect "Do you want to enable 3rd party authentication providers"
# No
send -- "�\[B"
send -- "\r"
expect "Do you want to add User Pool Groups?"
# Yes
send -- "\r"
expect "Provide a name for your user pool group:"
send -- "everyone\r"
expect "Do you want to add another User Pool Group"
# No
send -- "\r"
expect "Sort the user pool groups in order of preference"
send -- "\r"
expect "Do you want to add an admin queries API?"
# No
send -- "�\[B"
send -- "\r"
expect "Multifactor authentication"
# OFF
send -- "\r"
expect "Email based user registration/forgot password:"
# Enabled
send -- "\r"
expect "Specify an email verification subject:"
# Your verification code
send -- "\r"
expect "Specify an email verification message:"
# Your verification code is {####}
send -- "\r"
expect "Do you want to override the default password policy for this User Pool?"
# No
send -- "\r"
expect "Specify the app's refresh token expiration period (in days):"
# 30
send -- "\r"
expect "Do you want to specify the user attributes this app can read and write?"
# No
send -- "\r"
expect "Do you want to enable any of the following capabilities?"
# Group
send -- "�\[B"
send -- "�\[B"
send -- " "
send -- "\r"
expect "Do you want to use an OAuth flow?"
# No
send -- "�\[B"
send -- "\r"
expect "Do you want to configure Lambda Triggers for Cognito?"
# Yes
send -- "\r"
expect "Which triggers do you want to enable for Cognito"
# Post Confirmation
send -- "\r"
expect "What functionality do you want to use for Post Confirmation"
# Add User To Group, Create your own module
send -- "�\[B"
send -- "�\[B"
send -- " "
send -- "\r"
expect "Enter the name of the group to which users will be added."
send -- "everyone\r"
expect "Do you want to edit your add-to-group function now?"
# No
send -- "n\r"
expect "Do you want to edit your custom function now?"
# No
send -- "n\r"

interact

@fjnoyp
Copy link
Contributor

fjnoyp commented Jan 18, 2022

Hi @dorontal unfortunately I am not able to reproduce your problem on my side.

Please let me know if I didn't properly reproduce your setup. Also, perhaps your Lambda function is doing something strange?

Observed Behavior

When I run sign up, I get a lambda error but I didn't configure any lambda functions so that's expected. Out of curiosity what did you write in your lambda?

Console Output ``` E/amplify:flutter:auth_cognito( 2631): LambdaException E/amplify:flutter:auth_cognito( 2631): AuthException{message=Confirm sign up failed, cause=com.amazonaws.services.cognitoidentityprovider.model.UserLambdaValidationException: PostConfirmation failed with error callback is not a function. (Service: AmazonCognitoIdentityProvider; Status Code: 400; Error Code: UserLambdaValidationException; Request ID: 8e307518-9a5d-4247-9371-b0669d729eee), recoverySuggestion=See attached exception for more details.} E/amplify:flutter:auth_cognito( 2631): at com.amplifyframework.auth.cognito.util.CognitoAuthExceptionConverter.lookup(CognitoAuthExceptionConverter.java:126) ```

However, when I try to sign in and call await Amplify.Auth.getCurrentUser(); it succeeds:

I/flutter ( 2631): print current user: 
I/flutter ( 2631): Instance of 'AuthUser'
I/flutter ( 2631): kylcheng@gmail.com

Reproduction Steps

I am running Amplify CLI 7.6.3

When setting it up in Amplify for:
expect "Do you want to enable any of the following capabilities?" Was your choice - add user to group?

Here is what I did in Amplify CLI setup

image

For the code, I just used the new Amplify Authenticator component. It's really easy to setup and use:

Make sure to use amplify_authenticator: ^0.1.0-rc.3

https://docs.amplify.aws/ui/auth/authenticator/q/framework/flutter/

@dorontal
Copy link
Author

dorontal commented Jan 18, 2022

Hi @fjnoyp thank you very much for trying to reproduce the issue. Also thanks for the recommendation to use Authenticator - glad it's ready, I will try using it and most likely this issue will not exist when using the Authenticator. Will report.

There are two lambda functions in this case: one to add user to group (too default Amplify-generated code) and a custom one to create a default user profile model and store it in dynamo DB. Or I should say it's one lambda function, but two modules, as implemented by the Amplify CLI.

ps. just took a look at Authenticator and will wait until there is more documentation / examples for my specific use case (email-only sign-up), to evaluate it.

@dorontal
Copy link
Author

Just tried the AWS CLI version 7.6.11 and this issue still stands - it is still the same issue with the new version.

@dorontal
Copy link
Author

Just tried the Amplify CLI new version (v7.6.12) and the same bug exists with it.

This issue still causes no user to be able to log in to my app.

I see other issues that seem to indicate others may have the same problem, e.g. #1271

Also: I saw a similar problem with an Ionic/Angular version of the same app, so this may not be Flutter related - if I determine that, I will move this issue to @aws-cli issues.

@dorontal
Copy link
Author

Possibly related to this issue: aws-amplify/amplify-android#1635

@fjnoyp
Copy link
Contributor

fjnoyp commented Jan 27, 2022

Hi @dorontal I've invited you to the basic auth app with email only sign up setup with Authenticator. Could you see if running that locally still results in the same issue when calling await getCurrentUser() (just click the Print CurrentAuthUser button and look at logs)

Invite: https://github.com/fjnoyp/auth_test_app/invitations

@fjnoyp
Copy link
Contributor

fjnoyp commented Jan 27, 2022

If you don't have the issue in the basic auth app, I'd be curious to know if it works still after you swap in your own AmplifyConfiguration.dart file.

@dorontal
Copy link
Author

Hi @fjnoyp thanks for sharing this code! I just tried it and, interestingly, the same error / issue reported here showed up exactly in the same way: the Android logs of the running app in the VSCode console are saying

D/AWSMobileClient(22764): hasFederatedToken: false provider: cognito-idp.us-east-1.amazonaws.com/us-east-1_8J1noqvb8
W/AWSMobileClient(22764): Failed to federate tokens during sign-in
W/AWSMobileClient(22764): java.lang.RuntimeException: Error in federating the token.
...
W/AWSMobileClient(22764): Caused by: com.amazonaws.services.cognitoidentity.model.InvalidIdentityPoolConfigurationException: Invalid identity pool configuration. Check assigned IAM roles for this pool. (Service: AmazonCognitoIdentity; Status Code: 400; Error Code: InvalidIdentityPoolConfigurationException; Request ID: 7d5b346e-2d5d-456e-8069-14610779a1d7)

I have a couple of things going on with my configuration that are non-standard, they may be the cause, I checked them:

  1. Lambda triggers. I added a lot of print statements and can see that they terminate fine and do their work just as expected without any crashes so most likely they are not the cause of this issue.

  2. In my project I've set up first (via the AWS console) an attribute mapping for access control as described in this AWS article. In a previous issue, I actually have outlined exactly the changes that I made to the AWS setup of the current issue. These are in steps 1-4 in my comment here: How to find the bidirectional map between Cognito identity ID and Cognito user information? amplify-js#54 (comment)

I now believe that it is very possible that those steps 1-4 that were done for using attributes for access control may be what is causing the Amplify Authenticator (or my custom function calls) to fail in federating the token.

If my setup for using attributes for access control has caused this, I cannot see the reason why or the connection to the issue, but by elimination -- this may be the reason -- it's the main difference between my version of your app, which doesn't work, and yours, which does work.

I hope this helps.

@dorontal
Copy link
Author

dorontal commented Jan 28, 2022

@fjnoyp finally found what is causing the issue: played around today with the various differences between my setup and the one in the sample app you've given me. I do several things in my setup that your test program doesn't and one of them always causes this issue to come up. It is the step where I add "attributes for access control" as described in this AWS article and as I do by following Step 2 here.

When I add the attribute mapping cognitoId -> sub to set up attributes for access control, this issue comes up exactly as reported. When this mapping is removed, the issue disappears.

To reproduce make the following changes in the AWS console, up to step 2, described here add that mapping to any app that uses email/password - and you'll see the issue come up.

I also saw this behavior (this issue no longer an issue after you remove the attributes-for-access-control mapping) in an Angular version of the same app, so I don't think that this is Amplify-Flutter specific. I am not sure where the best place to put this issue with a new title like "Adding attributes for access control causes Cognito to fail to federate tokens and therefore makes sign-in impossible" - Amplify CLI? Once I figure out where to move this issue, if there's a better repository for it (amplify-cli?) I will move it.

@dorontal
Copy link
Author

dorontal commented Feb 1, 2022

@fjnoyp so to summarize, you can reproduce the issue fully: just add attributes for access control to your existing app, as described in steps 1 & 2 here -- all you need is to create the single mapping cognitoId -> sub and you'll not be able to sign any users in after that.

However, I now realize that this issue is not really Flutter-specific, probably, right? I would like to re-open this issue in the right place, if this repository is not perfect for it, but I'm having a difficult time figuring out which repository to open it in: amplify-cli?

@fjnoyp
Copy link
Contributor

fjnoyp commented Feb 2, 2022

Hi @dorontal seems like a cli issue. Thank you for the very detailed context. I'll check it out and confirm if cli repo is where you should open the issue.

@dorontal
Copy link
Author

dorontal commented Feb 11, 2022

Hi @fjnoyp - since it's been determined pretty clearly that this is a CLI issue, I opened this issue there in a more concise form. Closing this one for that reason. Thanks for all your help! Now moving this issue to

aws-amplify/amplify-cli#9747

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
auth Issues related to the Auth Category to-be-reproduced Issues that have not been reproduced yet, but have reproduction steps provided
Projects
None yet
Development

No branches or pull requests

5 participants