aws-amplify / aws-sdk-ios

AWS SDK for iOS. For more information, see our web site:
https://aws-amplify.github.io/docs
Other
1.67k stars 877 forks source link

[Crash] SDK 2.36.0 AWSCognitoAuth launchUsing:uiViewController:completion: #5315

Open skyfoxa opened 1 month ago

skyfoxa commented 1 month ago

Describe the bug Calling AWSMobileClient.default().showSignIn(navigationController: signInUIOptions: hostedUIOptions: _:) leads to an uncaught exception and crashes the app.

This issue started occurring when we updated the SDK from version 2.35.0 to 2.36.0. It's probably connected to the recent update from SFAuthenticationSession to ASWebAuthenticationSession. It may be the same issue as was discussed here

To Reproduce

Here is our awsconfiguration:

"Auth": {
      "Default": {
        "OAuth": {
          "WebDomain": "...",
          "AppClientId": "....",
          "SignInRedirectURI": "myapp://callback",
          "SignOutRedirectURI": "myapp://signout",
          "Scopes": ["openid", "email", "profile"]
        }
      }
    },

Steps to reproduce the behavior:

  1. Call AWSMobileClient.default().showSignIn(navigationController:signInUIOptions:hostedUIOptions:_:)
    • use HostedUIOptions(scopes: ["openid", "email", "profile"], identityProvider: "Google")

Observed Behavior

*** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: 'The provided scheme is not valid. A scheme should not include special characters such as ":" or "/".'

Expected Behavior Hosted UI is opened and user can sign in, app doesn't crash.

Stack Trace image

Code Snippet

Unique Configuration

Areas of the SDK you are using (AWSMobileClient, Cognito, Pinpoint, IoT, etc)? AWSMobileClient

Screenshots

Environment(please complete the following information):

Device Information (please complete the following information):

Additional context

Relevant Console Output

Logs

Log Messages ``` *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: 'The provided scheme is not valid. A scheme should not include special characters such as ":" or "/".' *** First throw call stack: (0x1a677ab28 0x19e5eaf78 0x21e71b618 0x21e71b214 0x10bb3dc10 0x10bb3dae0 0x10bb3da4c 0x1a55687f4 0x1a5596d0c 0x1a5594594 0x1a5593684 0x1a559619c 0x1a5595f08 0x10c617764 0x10c6067bc 0x10c6098e0 0x10c608bb8 0x10c61aae4 0x10c61b4d8 0x202670ee4 0x202670fc0) libc++abi: terminating due to uncaught exception of type NSException ```
ruisebas commented 4 weeks ago

Hi @skyfoxa! Thanks for opening this issue.

We will take a look and post updates here.

ruisebas commented 4 weeks ago

This should be fixed in the latest release 2.36.1.

Could you please update your dependency and verify? Thanks!

skyfoxa commented 3 weeks ago

@ruisebas the SDK doesn't crash anymore, however it won't open the hosted UI, calling the AWSMobileClient.default().showSignIn(navigationController: signInUIOptions: hostedUIOptions: _:) method returns this error:

Error Domain=com.apple.AuthenticationServices.WebAuthenticationSession Code=2 "Cannot start ASWebAuthenticationSession without providing presentation context. Set presentationContextProvider before calling -start." UserInfo={NSDebugDescription=Cannot start ASWebAuthenticationSession without providing presentation context. Set presentationContextProvider before calling -start.}
ruisebas commented 3 weeks ago

@skyfoxa my apologies for that.

I've merged a fix to the main branch. Would you be able to verify it it addresses your issues? If you cannot, no worries, we will release a new version for you to try.

Thanks!

skyfoxa commented 3 weeks ago

@ruisebas I tried it, but it looks https://github.com/aws-amplify/aws-sdk-ios-spm doesn't contain that change yet, I'll probably wait for the release

ruisebas commented 2 weeks ago

@skyfoxa sorry for the delay. The fix has been released in 2.36.2.

Please let us know if you still face any issues. Thanks!