Giter Club home page Giter Club logo

Comments (7)

ruisebas avatar ruisebas commented on June 15, 2024

Hi @howardkitto, thanks for opening this issue!

It seems that Amplify's signUp API is throwing an error which is not mapped to a localized string in the Authenticator, which is why a generic "Unknown error happened" is logged.

In order to get more information about the error, could you please enable Amplify's verbose logging and share the output? Just add this line in your code:

Amplify.Logging.logLevel = .verbose

Please make sure to remove any sensitive data that might be included.

Thanks!

from amplify-ui-swift-authenticator.

howardkitto avatar howardkitto commented on June 15, 2024

Thanks so much for getting back to me!

Here is my app code:

import Amplify
import Authenticator
import AWSCognitoAuthPlugin
import SwiftUI

@main
struct App: App {
    
    @StateObject var user = User()
    
    init() {
        do {
            try Amplify.add(plugin: AWSCognitoAuthPlugin())
            try Amplify.configure()
            Amplify.Logging.logLevel = .verbose
            
        } catch {
            print("Unable to configure Amplify \(error)")
        }
    }
    
    var body: some Scene {
        WindowGroup {
            Authenticator {state in
                ContentView(user: user)
                    .onAppear(perform: user.updateUser)
            }
        }
    }
}

And here are the logs from the point where Authenticator state is user is signedOut

2023-05-12 08:21:16.294526+0100 App[92283:2007082] [FetchAuthSessionOperationHelper] Received error - sessionError(AWSCognitoAuthPlugin.FetchSessionError.notAuthorized, noCredentials)
2023-05-12 08:21:16.295675+0100 App[92283:2007074] [AWSCognitoAuthPlugin] Auth state change:

{
    "AuthState.configured" =     {
        "AuthenticationState.signedOut" =         {
            lastKnownUserName = "(nil)";
        };
        "AuthorizationState.error" =         {
            Error = "AWSCognitoAuthPlugin.AuthorizationError.sessionError(AWSCognitoAuthPlugin.FetchSessionError.notAuthorized, noCredentials)";
        };
    };
}
2023-05-12 08:21:16.296053+0100 App[92283:2007078] [AuthenticatorState] The user is not signed in, going to signedOut step
2023-05-12 08:21:19.275421+0100 App[92283:2006981] [SignUpState] Reading Sign Up attributes from the Cognito configuration
2023-05-12 08:21:23.222857+0100 App[92283:2006981] [LayoutConstraints] Unable to simultaneously satisfy constraints.
	Probably at least one of the constraints in the following list is one you don't want. 
	Try this: 
		(1) look at each constraint and try to figure out which you don't expect; 
		(2) find the code that added the unwanted constraint or constraints and fix it. 
	(Note: If you're seeing NSAutoresizingMaskLayoutConstraints that you don't understand, refer to the documentation for the UIView property translatesAutoresizingMaskIntoConstraints) 
(
    "<NSAutoresizingMaskLayoutConstraint:0x600001053f70 h=--& v=--& _UIToolbarContentView:0x7fe936f0d5a0.width == 0   (active)>",
    "<NSLayoutConstraint:0x60000105d720 H:|-(16)-[_UIButtonBarStackView:0x7fe936f0df40]   (active, names: '|':_UIToolbarContentView:0x7fe936f0d5a0 )>",
    "<NSLayoutConstraint:0x60000105d770 H:[_UIButtonBarStackView:0x7fe936f0df40]-(16)-|   (active, names: '|':_UIToolbarContentView:0x7fe936f0d5a0 )>"
)

Will attempt to recover by breaking constraint 
<NSLayoutConstraint:0x60000105d770 H:[_UIButtonBarStackView:0x7fe936f0df40]-(16)-|   (active, names: '|':_UIToolbarContentView:0x7fe936f0d5a0 )>

Make a symbolic breakpoint at UIViewAlertForUnsatisfiableConstraints to catch this in the debugger.
The methods in the UIConstraintBasedLayoutDebugging category on UIView listed in <UIKitCore/UIView.h> may also be helpful.
2023-05-12 08:21:40.778080+0100 App[92283:2007077] [AutoFill] Cannot show Automatic Strong Passwords for app bundleID: HK.App due to error: iCloud Keychain is disabled
2023-05-12 08:21:48.565244+0100 PeakflowMobile[92283:2006981] [LayoutConstraints] Unable to simultaneously satisfy constraints.
	Probably at least one of the constraints in the following list is one you don't want. 
	Try this: 
		(1) look at each constraint and try to figure out which you don't expect; 
		(2) find the code that added the unwanted constraint or constraints and fix it. 
(
    "<NSLayoutConstraint:0x600001048370 'accessoryView.bottom' _UIRemoteKeyboardPlaceholderView:0x7fe943d0c380.bottom == _UIKBCompatInputView:0x7fe93700f300.top   (active)>",
    "<NSLayoutConstraint:0x6000010484b0 'assistantHeight' SystemInputAssistantView.height == 45   (active, names: SystemInputAssistantView:0x7fe937004e20 )>",
    "<NSLayoutConstraint:0x60000105b610 'assistantView.bottom' SystemInputAssistantView.bottom == _UIKBCompatInputView:0x7fe93700f300.top   (active, names: SystemInputAssistantView:0x7fe937004e20 )>",
    "<NSLayoutConstraint:0x600001048230 'assistantView.top' V:[_UIRemoteKeyboardPlaceholderView:0x7fe943d0c380]-(0)-[SystemInputAssistantView]   (active, names: SystemInputAssistantView:0x7fe937004e20 )>"
)

Will attempt to recover by breaking constraint 
<NSLayoutConstraint:0x600001048230 'assistantView.top' V:[_UIRemoteKeyboardPlaceholderView:0x7fe943d0c380]-(0)-[SystemInputAssistantView]   (active, names: SystemInputAssistantView:0x7fe937004e20 )>

Make a symbolic breakpoint at UIViewAlertForUnsatisfiableConstraints to catch this in the debugger.
The methods in the UIConstraintBasedLayoutDebugging category on UIView listed in <UIKitCore/UIView.h> may also be helpful.
2023-05-12 08:21:53.748349+0100 App[92283:2007077] [AutoFill] Cannot show Automatic Strong Passwords for app bundleID: HK.PeakflowMobile due to error: iCloud Keychain is disabled
2023-05-12 08:22:02.843105+0100 App[92283:2006981] [SignUpState] Attempting to Sign Up
2023-05-12 08:22:02.844379+0100 App[92283:2007715] [AWSAuthSignUpTask] Starting execution
2023-05-12 08:22:02.855074+0100 App[92283:2006981] [SignUpState] Unable to Sign Up
2023-05-12 08:22:02.859856+0100 App[92283:2006981] [SignUpState] The operation couldn’t be completed. (Amplify.AuthError error 3.)
2023-05-12 08:22:02.861037+0100 App[92283:2006981] [AuthenticatorError] The operation couldn’t be completed. (Amplify.AuthError error 3.)
2023-05-12 08:22:02.861190+0100 App[92283:2006981] [AuthenticatorError] Unknown error happened

from amplify-ui-swift-authenticator.

ruisebas avatar ruisebas commented on June 15, 2024

Thanks for sharing the logs! Unfortunately it seems they are not providing enough information to determine what the underlying Cognito error might be 😓 .

Would you be able to try using the ruisebas/adding_error_logs branch? I've added additional logging for errors that might provide the information we need without needing to manually debug.

Thanks!

from amplify-ui-swift-authenticator.

howardkitto avatar howardkitto commented on June 15, 2024

That's better - This was a fresh app and fresh amplify config, looks like something wrong with the username field:

2023-05-13 09:56:27.606910+0100 AmplifyUITest[16964:2289494] [SignUpState] Attempting to Sign Up
2023-05-13 09:56:27.610236+0100 AmplifyUITest[16964:2289706] [AWSAuthSignUpTask] Starting execution
2023-05-13 09:56:27.619139+0100 AmplifyUITest[16964:2289494] [SignUpState] Unable to Sign Up
2023-05-13 09:56:27.624730+0100 AmplifyUITest[16964:2289494] [SignUpState] The operation couldn’t be completed. (Amplify.AuthError error 3.)
2023-05-13 09:56:27.625482+0100 AmplifyUITest[16964:2289494] [SignUpState] AuthError: Username is required to signUp
Recovery suggestion: Make sure that a valid username is passed for signUp
2023-05-13 09:56:27.625624+0100 AmplifyUITest[16964:2289494] [SignUpState] Unable to localize error that is not of type AWSCognitoAuthError
2023-05-13 09:56:27.626543+0100 AmplifyUITest[16964:2289494] [AuthenticatorError] Creating an unknown AuthenticatorError
2023-05-13 09:56:27.626650+0100 AmplifyUITest[16964:2289494] [AuthenticatorError] AuthError: Username is required to signUp
Recovery suggestion: Make sure that a valid username is passed for signUp

Here is the config (redacted)

{
    "UserAgent": "aws-amplify/cli",
    "Version": "0.1.0",
    "IdentityManager": {
        "Default": {}
    },
    "CredentialsProvider": {
        "CognitoIdentity": {
            "Default": {
                "PoolId": "###",
                "Region": "eu-west-2"
            }
        }
    },
    "CognitoUserPool": {
        "Default": {
            "PoolId": "eu-west-2_###,
            "AppClientId": "###",
            "Region": "eu-west-2"
        }
    },
    "Auth": {
        "Default": {
            "authenticationFlowType": "USER_SRP_AUTH",
            "socialProviders": [],
            "usernameAttributes": [
                "EMAIL"
            ],
            "signupAttributes": [
                "EMAIL"
            ],
            "passwordProtectionSettings": {
                "passwordPolicyMinLength": 8,
                "passwordPolicyCharacters": []
            },
            "mfaConfiguration": "OFF",
            "mfaTypes": [
                "SMS"
            ],
            "verificationMechanisms": [
                "EMAIL"
            ]
        }
    }
}

Maybe it is because I chose this option?

 "usernameAttributes": [
                "EMAIL"
            ],

from amplify-ui-swift-authenticator.

ruisebas avatar ruisebas commented on June 15, 2024

Yep, the Authenticator has an issue that prevents from signing up when using either EMAIL or PHONE_NUMBER as the username attribute.
I'm working on submitting a fix for this.

from amplify-ui-swift-authenticator.

ruisebas avatar ruisebas commented on June 15, 2024

@howardkitto the fix has been merged into main.
Could you please validate if your issue is solved? Thanks!

from amplify-ui-swift-authenticator.

howardkitto avatar howardkitto commented on June 15, 2024

Yes! This works perfectly now - thanks so much!

from amplify-ui-swift-authenticator.

Related Issues (18)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.