amplify-android: Sign in with web UI failed

Hello I am receiving AmplifyException when I login using Facebook/Google.

You can see my manifest here:

<activity
        android:name=".login.SocialLoginActivity"
        android:label="@string/title_activity_social_login"
        android:theme="@style/AppTheme.NoActionBar"
        android:launchMode="singleInstance">
    <intent-filter>
        <action android:name="android.intent.action.VIEW" />
        <category android:name="android.intent.category.DEFAULT" />
        <category android:name="android.intent.category.BROWSABLE" />
        <data android:scheme="myapp" />
    </intent-filter>
</activity>

And here is my Activity:

class SocialLoginActivity : AppCompatActivity() {

    lateinit var loginType: String
    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        setContentView(R.layout.activity_social_login)
        //  setUpToolBar("Social")
        if (intent != null && intent.hasExtra(AppText.ARG_PARAM_SOCIAL_LOGIN_TYPE))
            loginType = intent.extras.getString(AppText.ARG_PARAM_SOCIAL_LOGIN_TYPE)

        Timber.d("the login type is:" + loginType)
        if (loginType.equals("facebook")) {
            Amplify.Auth.signInWithSocialWebUI(
                AuthProvider.facebook(),
                this,
                { result ->
                    Timber.d(result.toString())
                    handleLoginSuccess()
                },
                { error ->
                    Timber.d(error.toString())
                    handleLoginFailure(error.toString())
                }
            )
        } else if (loginType.equals("google")) {
            Amplify.Auth.signInWithSocialWebUI(
                AuthProvider.google(),
                this,
                { result -> handleLoginSuccess() },
                { error ->
                    Timber.d(error.toString())
                    handleLoginFailure(error.message.toString()) }
            )
        }
    }

    override fun onNewIntent(intent: Intent?) {
        super.onNewIntent(intent)
        Timber.d("inside on New intent called" + intent.toString())
        if (intent?.scheme != null && "myapp".equals(intent?.scheme)) {
            Timber.d("inside handle webui signin")
            Amplify.Auth.handleWebUISignInResponse(intent)
            // authViewModel.handleSocialSignIn(intent)
        }
    }

    fun handleLoginFailure(failureMessage: String) {
        Timber.d("inside failure")
        //Toast.makeText(this, failureMessage, Toast.LENGTH_SHORT)
        finish()
    }
    fun handleLoginSuccess() {
        Timber.d("inside handle login suxxess")
      //  finish()
        startSplashActivity()
    }
}

The error is:

AmplifyException {message=Sign in with web UI failed, cause=com.amazonaws.mobileconnectors.cognitoauth.exceptions.AuthNavigationException: user cancelled, recoverySuggestion=See attached exception for more details}

About this issue

  • Original URL
  • State: closed
  • Created 4 years ago
  • Reactions: 1
  • Comments: 21 (10 by maintainers)

Most upvoted comments

Heads up that we found a way to fix this issue and will be implementing it soon.

Basically we’ll include two activities in the library, one which will launch the custom Chrome tab and one which will handle the callback URL and return the response so you don’t have to worry about modifying the manifest, passing an activity in the method, and setting up the onNewIntent listener like you do now.

@TrekSoft Maybe this is something we can have on-call look at?