4

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.

1 Answer 1

1

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.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.