Skip to content

AuthError: Unexpected error occurred with message: Unsupported next step: completeAutoSignIn #106

Closed
@tmccaffrey914

Description

@tmccaffrey914

Describe the bug

During the "Sign Up" flow (so when creating a new user not authenticating an existing user) & after receiving and inputting the Email verification code - the authentication fails. In Cognito, I can see that the user was verified correctly & when you navigate back to the regular login screen and attempt to login - it's successful. Screen recording attached.

Before going into the steps to reproduce, I've tracked the issue down to this switch statement. When I run my signup flow the result is set to completeAutoSignIn with an associated Session Token. Since there is no case for completeAutoSignIn, program enters the default block which results in the error.

Screen Recording 2025-02-16 at 20.01.08.mov.zip

Steps To Reproduce

Steps to reproduce the behavior:
1. Set up a simple iOS app with only the Authenticator view:

    init() {
        do {
            try Amplify.add(plugin: AWSCognitoAuthPlugin())
            try Amplify.configure(with: .amplifyOutputs)
        } catch {
            print("Unable to configure Amplify \(error)")
        }
    }
    var body: some Scene {
        WindowGroup {
            Authenticator { state in
                RootView()
            }
        }
    }

2. Use the following `amplify_outputs.json`, no need for any amplify backend - I'm just using Cognito to generate session tokens to authenticate a different API Gateway.

{
  "version": "1",
  "auth": {
    "user_pool_id": "xxxxxxxxxxxxxx,
    "aws_region": "xxxxxxx",
    "user_pool_client_id": "xxxxxxxxxxxxx",
    "identity_pool_id": "xxxxxxxxxxxxxxxx",
    "mfa_methods": [],
    "standard_required_attributes": [
      "email"
    ],
    "username_attributes": [
      "email"
    ],
    "user_verification_types": [
      "email"
    ],
    "groups": [],
    "mfa_configuration": "NONE",
    "password_policy": {
      "min_length": 8,
      "require_lowercase": true,
      "require_numbers": true,
      "require_symbols": true,
      "require_uppercase": true
    },
    "unauthenticated_identities_enabled": true
  }
}

3. Here is my Cognito App Client configuration:

Identity Provider - Cognito User Pool
OAuth 2.0 Grant Type - Authorization Code Grant
OpenID Connect Scopes - Email, Phone, OpenID


Authentication flows:
Enabled: Choice-based sign-in: ALLOW_USER_AUTH
Enabled: Sign in with username and password: ALLOW_USER_PASSWORD_AUTH
Enabled: Sign in with secure remote password (SRP): ALLOW_USER_SRP_AUTH
Disabled: Sign in with server-side administrative credentials: ALLOW_ADMIN_USER_PASSWORD_AUTH
Disabled: Sign in with custom authentication flows from Lambda triggers: ALLOW_CUSTOM_AUTH
Enabled: Get new user tokens from existing authenticated sessions: ALLOW_REFRESH_TOKEN_AUTH

4. Try to "Sign Up" with a new user through the iOS simulator Login UI, after you enter the Email Verification code, a generic error appears on the screen and this error in the logs:
> AuthError: Unexpected error occurred with message: Unsupported next step: completeAutoSignIn("xxxxxxxxx-ThisWasASessionToken-xxxxxxxxxxx")
Recovery suggestion: This should not happen. There is a possibility that there is a bug if this error persists. Please take a look at https://github.com/aws-amplify/amplify-swift/issues to see if there are any existing issues that match your scenario, and file an issue with the details of the bug if there isn't.
5. Leave the "Sign Up" flow and go into the regular "Log In" flow and successfully log in with the new users details. Proving that the account was successfully added to the Userpool and successful Login is possible with the same credentials.

Expected behavior

The "Sign Up" flow should take you into the app the same way as would happen if you "Logged In"

Amplify Framework Version

2.45.4

Amplify Categories

Auth

Dependency manager

Swift PM

Swift version

5

CLI version

I uninstalled the CLI because I only need the Auth View

Xcode version

16.2 - 16C5032a

Relevant log output

<details>
<summary>Log Messages</summary>


AuthError: Unexpected error occurred with message: Unsupported next step: completeAutoSignIn("xxxxxxxxx-ThisWasASessionToken-xxxxxxxxxxx")
Recovery suggestion: This should not happen. There is a possibility that there is a bug if this error persists. Please take a look at https://github.com/aws-amplify/amplify-swift/issues to see if there are any existing issues that match your scenario, and file an issue with the details of the bug if there isn't.

</details>

Is this a regression?

No

Regression additional context

No response

Platforms

iOS

OS Version

iOS 18.2

Device

iPhone 16 Pro

Specific to simulators

No response

Additional context

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions