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}
Hey, so that's a valid error if the user cancels out of the web view which pops up without signing in. Is this happening even if the user signs in successfully?
Yes @TrekSoft I am getting AmplifyException but the user signs in successfully. It is a weird scenario.
Ok yeah so this appears to be due to this underlying cause in the library we've tentatively built Auth on top of: https://github.com/aws-amplify/aws-sdk-android/issues/871
I'll be looking into a fix for this here.
Can you check if your "inside handle webui signin" log is being printed out? Or even just "inside on New intent called"? Also did you migrate from AWSMobileClient or is this a fresh project on Amplify?
@TrekSoft The log is being printed inside the error and the onNewIntent() is not called. This is the error that was printed:
AmplifyException {message=Sign in with web UI failed, cause=com.amazonaws.mobileconnectors.cognitoauth.exceptions.AuthNavigationException: user cancelled, recoverySuggestion=See attached exception for more details}
Ok so if onNewIntent is not being called, there's some problem in your setup. Can you post the SignInRedirectURI and SignOutRedirectURI values you have in the amplifyconfiguration.json?
@TrekSoft These are the SignInRedirectURI and SignOutRedirectURI
"SignInRedirectURI": "myapp://callback/",
"SignOutRedirectURI": "myapp://signout/",
Hmm, this is very strange. I'll have to test your sample code for myself sometime here to see if I can replicate it.
@TrekSoft Maybe this is something we can have on-call look at?
Hello, I am also getting the same issue. Did anyone solved it?
We haven't gotten to it yet - could you post your activity code and put a log in to check whether it's hitting the onNewIntent method?
The error is thrown before hitting the onNewIntent method.
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 Any updates on this issue? I am also getting the same issue.
Yup, I'm working on the fix this sprint.
The fix for this has just been released in version 1.2.0. Note that a slight setup change is needed so please follow the updated documentation here to correct your environment: https://docs.amplify.aws/lib/auth/signin_web_ui/q/platform/android#update-androidmanifestxml
Most helpful comment
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.