Support Topics Documentation Slack YouTube Blog

Exception when logging in with Facebook in Android

Facebook login is working in my app with com.backendless:backendless:6.0.1 and com.facebook.android:facebook-login:5.8.0. Today I tried to update to com.backendless:backendless:6.2.1 and migrate to the new OAuth2 login. I get the following exception:

BackendlessFault{ code: ‘Server.Processing’, message: ‘com.fasterxml.jackson.databind.exc.MismatchedInputException: Cannot deserialize instance of java.util.ArrayList<com.backendless.services.users.entity.UsersEntityDescription$OAuthIdentity> out of START_OBJECT token
at [Source: UNKNOWN; line: -1, column: -1]’, detail: ‘com.fasterxml.jackson.databind.exc.MismatchedInputException: Cannot deserialize instance of java.util.ArrayList<com.backendless.services.users.entity.UsersEntityDescription$OAuthIdentity> out of START_OBJECT token
at [Source: UNKNOWN; line: -1, column: -1]’, extendedData: ‘{}’ }

This is my code:

Backendless.UserService.loginWithOAuth2("facebook", accessToken, null, new AsyncCallback<BackendlessUser>() {
            @Override
            public void handleResponse(BackendlessUser user) {
                    Backendless.UserService.setCurrentUser(user);
                    loginCallback.onLoginSuccess(user.getUserId());

                FirebaseCrashlytics.getInstance().setUserId(user.getUserId());
            }

            @Override
            public void handleFault(BackendlessFault fault) {
                loginCallback.onLoginFailure(fault.getMessage());
            }
        },
        true);

I have tried both with the old com.facebook.android:facebook-login:5.8.0 and the latest com.facebook.android:facebook-login:9.0.0 and the result is the same.

P.S. Just reverted back to com.backendless:backendless:6.0.1 and it turns out the exception is happening there, too. So, it’s not caused by the new SDK.

Hi, @milen-marinov

The internal ticket (BKNDLSS-24364) has been created. Your problem will be investigated and fixed as soon as possible.

Regards,
Marina

1 Like

Hi @milen-marinov !

Could you please provide your App ID and check if error still present?

Regards, Andriy

Hi @Andriy_Konoz ,

Error is still present and my App ID is BDCD56B9-351A-E067-FFA4-9EA9CF2F4000.

Hi @milen-marinov !

I have several additional questions:

  1. Are you trying to log in existing user or trying to create new one?
  2. Do you modify “oAuthIdentities” field of “Users” table in your code? If yes - how?

We tried to reprocude this error in own apps on production but without any luck. I think that it can be in some way related to a way in which you modify “oAuthIdentities” field. I have checked your “Users” table and found out that some “OAuth” users at March 14 got wrong values for this field.

Regards, Andriy

Hi @Andriy_Konoz ,

  1. I tried with existing user
  2. No, haven’t done any modifications there

Best,
Milen

The problem still occurs. Do you need any more info for investigating it?

Hi @milen-marinov!
Sorry for delay. We have localized problem to update operation. By some reason structure for JSON column is saved to database in wrong way. We are working on solution for this problem. I or my colegue will notify you when fix will be awailable.

As temporal bypass for this problem you can perform bulkUpdate for your “Users” table and set “oAuthIdentities” column to “[]” value for all records where “accountType” is “OAUTH”. Your users still will be able to login under their existing accounts. During first login after bulk operation Backendless will add correct elements to “oAuthIdentities”

Regards, Andriy

1 Like

@milen-marinov
Could you please describe main scenarios for interaction with “Users” table in your app?
I am interested in ways in which you update it in database.
Do you use UserService or Persistence/Data to update users data? If you use Persistence/Data service - do you use map-driven approach or custom entity class?

Regards, Andriy

I update the “Users” table in two ways:

  1. Directly updating a custom property:

    Backendless.UserService.CurrentUser().setProperty(USER_ACCEPTED_PRIVACY_POLICY_FIELD, true);
    Backendless.UserService.update(Backendless.UserService.CurrentUser(), new AsyncCallback<BackendlessUser>() {...
    
  2. Setting relations to entries in other tables like this:

    HashMap<String, Object> childObject = new HashMap<>();
    childObject.put(OBJECT_ID_FIELD, currentUser.getObjectId());
    
    ArrayList<Map> children = new ArrayList<>();
    children.add(childObject);
    
    Backendless.Data.of(getTableName()).setRelation(parentObject, SIGNAL_AUTHOR, children, new AsyncCallback<Integer>() {...

Hi @milen-marinov !

Have you tried to reset oAuthIdentities for your users?
We have checked all possible scenarios and failed to reproduce your probelm. I suppose that it could be some misbehavior which was eliminated in one of recent releases.

Regards, Andriy

It looks like the problem was caused by v6.0.1 of your Android SDK. I tried to reset the wrong oAuthIdentities several times but they kept appearing until I released a new version of the app with SDK v6.2.1. There haven’t been any new users with wrong oAuthIdentities in the past 24 hours.

Hello @milen-marinov

We are glad to know that you were able to solve the problem. We are sorry for the inconvenience.

Regards,
Inna

It would be nice if such backwards-incompatible changes are known in advance, announced and introduced with proper deadlines. It would be even nicer if they don’t happen at all!

1 Like