Social Login in Syncano doesn't work with custom profile. I use SocialAuthBackend.FACEBOOK
and pass a token with custom class such as:
@SyncanoClass(name = "user_profile")
public class UserProfile extends AbstractUser {
}
together as:
syncano.loginSocialUser(UserProfile.class, SocialAuthBackend.FACEBOOK, loginResult.getAccessToken().getToken()).sendAsync(new SyncanoCallback<UserProfile>() {
//...
});
Which result in:
IllegalArgumentException: field com.syncano.library.data.AbstractUser.profile has type com.syncano.library.data.Profile, got com.google.gson.internal.LinkedTreeMap
at java.lang.reflect.Field.set(Native Method)
at java.lang.reflect.Field.set(Field.java:557)
at com.google.gson.internal.bind.ReflectiveTypeAdapterFactory$1.read(ReflectiveTypeAdapterFactory.java:119)
at com.google.gson.internal.bind.ReflectiveTypeAdapterFactory$Adapter.read(ReflectiveTypeAdapterFactory.java:217)
at com.google.gson.Gson.fromJson(Gson.java:861)
at com.google.gson.Gson.fromJson(Gson.java:826)
at com.google.gson.Gson.fromJson(Gson.java:775)
at com.google.gson.Gson.fromJson(Gson.java:747)
Can't fix it or find any sample online using this feature (or docs on this).
When you want to declare own user profile you should create 2 class:
AbstractUser<T>
(where T
is your profile class name) UserProfile
class with extend Profile
class (from syncano package
).Sample code:
@SyncanoClass(name = "user_profile")
public class MyUserProfile extends Profile {
@SyncanoField(name = "avatar")
public SyncanoFile avatar;
}
public class CustomUser extends AbstractUser<MyUserProfile> {
public CustomUser(String login, String pass) {
super(login, pass);
}
}
Soon release:
From version 4.0.6 (not published yet) you don't need anymore @SyncanoClass annotation in profile (optional).