Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

387
Visualizações
Unity Firebase Authentication CreateUserWithEmailAndPasswordAsync returns empty UserID

When I run CreateUserWithEmailAndPasswordAsync() the task returns as IsCompleted and the FirebaseUser is also not null, but the UserID and email are null/empty. I can see the new user (with UserID) in the firebase console.

The same thing happens when trying to SignInWithEmailAndPasswordAsync() with the newly created User. But when I SignInWithEmailAndPasswordAsync() with an older user account everything works fine.

It's strange because it is the same code I used a year ago. In the mean time I did update the Firebase SDK to 7.0.2. Could that be the cause of the issue?

Here is my code for creating a new user:

public static async Task<CallbackMessage> RegisterNewUser(string email, string password)
        {
            CallbackMessage callback = new CallbackMessage();
            callback.isSuccess = false;

            if (!await DatabaseManager.CheckConnection())
            {
                callback.notConnected = true;
                return callback;
            }

            return await auth.CreateUserWithEmailAndPasswordAsync(email, password).ContinueWith(task =>
            {
                if (task.IsCanceled)
                {
                    callback.errorMessage = "Create User was canceled";
                }
                else if (task.IsFaulted)
                {
                    callback.errorMessage = GetErrorMessage(task.Exception);
                }
                else if (task.IsCompleted)
                {
                    FirebaseUser newUser = task.Result;
                    Debug.Log("User created succesfully! userID: " + newUser.UserId);
                    callback.userID = newUser.UserId;
                    callback.email = newUser.Email;
                    callback.isSuccess = true;
                }

                CleanTask(task);
                return callback;
            });
        }

Could really use a nudge in the right direction on this one :)

over 4 years ago · Santiago Trujillo
1 Respostas
Responde à pergunta

0

I was able to solve it. Apologies for doubting the Firebase Auth service.

In my AuthStateChanged code I added a Signout() whenever a user signed in, but wasn't emailVerified yet. That's where the problem was.

My guess what happened: When user creation is called it signs the user in immediately, then goes to Firebase to set things up there. In the mean time I sign out the user because it's not email verified. When the callback comes back it looks for the FirebaseUser that it signed in before going to Firebase, but finds nothing.

Something like pulling the chair from underneath someone as he's about to sit :P

over 4 years ago · Santiago Trujillo Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda