strongloop-community/loopback-sdk-android

Issue with UserRepository.loginuser

omasabdullah opened this issue · 2 comments

Hi there, I have a User model as well as a User Repository set up however when i call the login feature the onError is always called with the message "Expecting a JSON object". Here is the code:

UserRepository userRepo = mAdapter.createRepository(UserRepository.class);
            userRepo.loginUser(mUsername.getText().toString(), mPassword.getText().toString(),
                    new UserRepository.LoginCallback() {
                        @Override
                        public void onSuccess(AccessToken token, User user) {
                            Log.d("TAG", "LOGIN SUCCESS");
                        }

                        @Override
                        public void onError(Throwable t) {
                            Log.d("TAG", "LOGIN FAILURE: " + t.getMessage());
                        }
                    });

Here is the UserRepository (extended from the strongloop UserRepository)

package com.oneset.oneset.model;

public class UserRepository extends com.strongloop.android.loopback.UserRepository<User> {
    public interface LoginCallback extends com.strongloop.android.loopback.UserRepository.LoginCallback<User> {}
    public UserRepository() {
        super("User", null, User.class);
    }

}

If you could shed some help as to what I am doing wrong or missing I would really appreciate it.

I need more information to be able to help you.

  1. Run your app in the Android Emulator
  2. Make sure debug logs are enabled (the following call must return true: android.util.Log.isLoggable("remoting.RestAdapter", Log.DEBUG)).
  3. Reproduce the error
  4. Look at the logs produces by the emulator and search for "Success (string): ", it will contain the original server response. Also look for the log containing the request, it will be a line like POST /api/Users/login followed by the JSON request body.
  5. Post both the request and response logs here.

As part of our issue triage process, we are closing items that have been inactive for an extended period of time. Feel free to reopen this issue if you can provide any new information to help us with resolving the issue.