user48445
user48445

Reputation: 41

Android AWS Amplify - library attempted to call user callback twice, expected only once

I've been stuck making AWS Amplify Auth on Android work. I have set up a custom OTP only/custom challenge flow. When I try to sign in using the following code block, the logcat returns

library attempted to call user callback twice, expected only once.

Amplify.Auth.signIn(
   "+***",
   null, //to make CUSTOM_CHALLENGE work
   result -> Log.i("AuthQuickstart", result.isSignInComplete() ? "Sign in succeeded" : "Sign in not complete"),
   error -> Log.e("AuthQuickstart", error.toString())
);

On Lambda side, CreateAuth lambda is generating an OTP and sending it to the user phone. This part works fine.

Also, how do I answer the custom challenge in Android? In Javascript, I could use

const cognitoUser = await Auth.sendCustomChallengeAnswer(user, OTP);

but there is no such method in Android.

Upvotes: 4

Views: 900

Answers (1)

RichardMcClellan
RichardMcClellan

Reputation: 465

You should be able to pass your OTP to the confirmSignIn method, like this:

Amplify.Auth.confirmSignIn(OTP, 
    result -> Log.i("AuthQuickstart", "Sign in confirmed"),
    error -> Log.e("AuthQuickstart", "Sign in failed", error)
);

Regarding the warning messages ("library attempted to call user callback twice, expected only once."), you can ignore them, they don't indicate that there is actually a problem.

Upvotes: 1

Related Questions