'Amplify CUSTOM_AUTH login issue on iOS swift

I am new to Amplify and want to integrate it with iOS swift. I followed amplify_doc to and created amplifyconfiguration.json and added it to the project. Configured with credentials provided such as PoolId, Region, AppClientId and web domain. Set authentication flow type as "authenticationFlowType": "CUSTOM_AUTH".

I tried with simple sign-in API with username as:

Amplify.Auth.signIn(username: userName) { result in
   switch result {
   case .success:
      print("Sign in succeeded")
   case .failure(let error):
      print("Sign in failed \(error)")
      if let err = error.underlyingError as NSError? {
          print("Cast to nserror:", err)
      }
   }

Error: Sign in failed AuthError: Incorrect username or password. This was password less authentication which works on Android but facing issues on iOS.

Also tried with Amplify.Auth.signIn(username: <username>, password: nil) still no success. When nothing worked I tried with signUp API it worked and I received OTP on email successfully. The issue seems to be in the sign-in API.



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source