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

Empty CognitoSignUpOptions are required when using the Amplify.Auth.signUp() #292

Closed
LeFrosch opened this issue Jan 4, 2021 · 1 comment
Assignees
Labels
auth Issues related to the Auth Category

Comments

@LeFrosch
Copy link

LeFrosch commented Jan 4, 2021

Only the username and password are marked with required for Amplify.Auth.signUp, but when I don’t pass an empty instance SignUpOptions I get the following error.

Invocation:

Future<bool> register(String email, String password) async {
  final result = await Amplify.Auth.signUp(
    username: email,
    assword: password,
  );

  return result.isSignUpComplete;
}

Error:

E/amplify:flutter:auth_cognito(23284): java.lang.Exception: AMPLIFY_REQUEST_MALFORMED
E/amplify:flutter:auth_cognito(23284): 	at com.amazonaws.amplify.amplify_auth_cognito.AuthCognito.onSignUp(AuthCognito.kt:218)
E/amplify:flutter:auth_cognito(23284): 	at com.amazonaws.amplify.amplify_auth_cognito.AuthCognito.onMethodCall(AuthCognito.kt:128)
E/amplify:flutter:auth_cognito(23284): 	at io.flutter.plugin.common.MethodChannel$IncomingMethodCallHandler.onMessage(MethodChannel.java:233)
E/amplify:flutter:auth_cognito(23284): 	at io.flutter.embedding.engine.dart.DartMessenger.handleMessageFromDart(DartMessenger.java:85)
E/amplify:flutter:auth_cognito(23284): 	at io.flutter.embedding.engine.FlutterJNI.handlePlatformMessage(FlutterJNI.java:692)
E/amplify:flutter:auth_cognito(23284): 	at android.os.MessageQueue.nativePollOnce(Native Method)
E/amplify:flutter:auth_cognito(23284): 	at android.os.MessageQueue.next(MessageQueue.java:336)
E/amplify:flutter:auth_cognito(23284): 	at android.os.Looper.loop(Looper.java:174)
E/amplify:flutter:auth_cognito(23284): 	at android.app.ActivityThread.main(ActivityThread.java:7710)
E/amplify:flutter:auth_cognito(23284): 	at java.lang.reflect.Method.invoke(Native Method)
E/amplify:flutter:auth_cognito(23284): 	at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:516)
E/amplify:flutter:auth_cognito(23284): 	at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:950)
I/flutter (23284): Unrecognized auth error returned from platform. See logs for details

I personally don’t think the error message conveys that the SignUpOptions are missing and additionally the options are not marked as required. To fix this error I created an empty map and passed it to the SignUpOptions, like that:

Future<bool> register(String email, String password) async {
  final result = await Amplify.Auth.signUp(
    username: email,
    password: password,
    options: CognitoSignUpOptions(userAttributes: <String, dynamic>{}),
  );

  return result.isSignUpComplete;
}

I don’t know if this is relevant but I configured the Cognito User Pool to use an email address as the username to sign up and sign in. Also I did not select any standard attributes.

Platform: Android
Device: OnePlus 7T (HD1903)
Android Version: 10
SDK Version: 29

Flutter Version: 1.22.5
Amplify Version: 0.0.1-dev.5

@haverchuck haverchuck added the auth Issues related to the Auth Category label Jan 7, 2021
@ragingsquirrel3 ragingsquirrel3 self-assigned this May 18, 2021
@ragingsquirrel3 ragingsquirrel3 removed their assignment Jun 2, 2021
@Jordan-Nelson Jordan-Nelson self-assigned this Jun 10, 2021
@Jordan-Nelson Jordan-Nelson added the pending-release Issues that have been addressed in main but have not been released label Jul 9, 2021
@Jordan-Nelson Jordan-Nelson removed the pending-release Issues that have been addressed in main but have not been released label Jul 28, 2021
@Jordan-Nelson
Copy link
Member

@LeFrosch thanks for opening this issue. This should be fixed as of version 0.2.1. signUp() does not require options (same behavior as you mentioned), but with 0.2.1, signUp should work without them for standard email based auth.

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
Projects
None yet
Development

No branches or pull requests

4 participants