Convert Guest User to Logged in User


I want to figure how to convert guest user into logged in user.

I am not registering new user. The user already exists. But she logged out and now restarted the app with guest login. Now when she logs in, all the guest data should link back to actual account.

Could not find the code in documentation for this point.

Hi @Ali_Sakhi

Here you go Guest Login API - Backendless SDK for JavaScript API Documentation

Regards, Vlad

This article shows new user registration.
Will it work the user already exists.

Guest user accounts created with the Anonymous Login API documented below can be “converted” to regular users using the User Registration API. The BackendlessUser object used in the registration request must contain the same value for the objectId property as the one returned in the response for the Anonymous Login API request.

according to the first paragraph it does

This is not working. This is trying to create a new user and it fails, as the user already exists.

@Ali_Sakhi what sdk are you using for this?
Can you send me example of your request thats not working as expected?


I am using the dotnet sdk. The requirement is to convert guest user to existing user after login.

As per doc the only option is that guest user can be converted into new registration.

What I am trying to do is I have list of cart items for guest user, and as soon as they login the cart should be assigned to logged in user.

I tried to convert guest login to logged in user and have not any problems. Can you share with me your code with convertation user?

Below is the code. Please note the user already exists in users table.

public void Login()
        var guestUserId = Backendless.UserService.LoggedInUserObjectId();

        AsyncCallback<BackendlessUser> callback = new AsyncCallback<BackendlessUser>(
            user =>
                //Shell.Current.DisplayAlert("Success", "User logged in. Assigned ID - " + user.ObjectId, "OK");
                Globals.LoggedCustomerId = user.ObjectId;
                Globals.UserEmail = user.Email;


                GuestUserConversion(guestUserId, user);

            fault =>
                    Shell.Current.DisplayAlert("Error", fault.Message, "OK");

        IsBusy = true;
        Backendless.UserService.Login(UserName, Password, callback, true);
        IsBusy = false;

    public void GuestUserConversion(string guestId, BackendlessUser user)
        BackendlessUser guestConversionUser = new BackendlessUser();
        guestConversionUser.Email = user.Email;
        guestConversionUser.Password = Password;
        guestConversionUser.SetProperty("objectId", guestId);
        Backendless.UserService.Register(guestConversionUser, new AsyncCallback<BackendlessUser>(
                registeredUser =>
                    var x = registeredUser;
                fault =>
                    System.Diagnostics.Debug.WriteLine($"An error has occurred, the error code: {fault.FaultCode}");

Are you sure the user you are trying to convert is a guest user?
You are converting a user who has a well-defined email and password. This is not a guest user. Therefore you are getting an error.

      var res = Backendless.UserService.LoginAsGuest();
      BackendlessUser registeredUser = new BackendlessUser();
      registeredUser.Email = "";
      registeredUser.Password = "123234";
      registeredUser.ObjectId = res.ObjectId;

      registeredUser = Backendless.UserService.Register(registeredUser);

You can see correct example above.

Best Regards, Nikita.

This is what I have been saying, it supports new user registration. I want to login with existing user.

Lets say user runs the app first time, and it logs in as guest. Then they register. Then sign out and closes the app,.
Next time they run the app and logs in as guest again. Now they will login (not register), so I want all the guest user data to be moved to the logged in user. How is that possible?

If I understood you correctly - you need to do this:
You need to get user(that user registered early) by objectId from database. Then put properties(that you need to update) from guest user to user that you got. Then you need to update user and login to it with login and password.

Almost. I want to move the guest user data for example cart items, to the new logged in user.

I know I can manually do it, but is there automated way in sdk.

Hello @Ali_Sakhi,
the instructions provided by Nikita are most suitable for this case.