Error: Missing username parameter

I have generated a one time code using AuthenticationAPIClient, and I am calling the authAPIClient.loginWithPhoneNumber(phonenumber, code) method.

But this is failing with the error:

code = invalid_request  
description = missing username parameter

Is there something I am missing?

Looks like someone has resolved it here by changing their url from http to https: https://auth0.com/forum/t/solved-error-missing-username-parameter-but-im-not/1546/2

I don’t think I can do it here as I am using android library and do not give a URL anywhere.

When using the authAPIClient.loginWithPhoneNumber(phoneNumber, verificationCode) method the phonenumber is used as the username in the underlying authentication API call.

public AuthenticationRequest loginWithPhoneNumber(@NonNull String phoneNumber, ...) {
    Map<String, Object> parameters = ParameterBuilder.newAuthenticationBuilder()
            .set(USERNAME_KEY, phoneNumber)

(source: AuthenticationAPIClient.java)

The simplest explanation to that error, although it may not be the right one for this scenario, would be that the phonenumber you’re passing to the method is empty. I would start by ensuring that this can’t happen.

Sometime simplest explanation is the right one! I too had a look at the method source code, still did not think I was passing empty phone number to api call!