Hello,
I’m currently stuck with Backendless.UserService.loginWithGooglePlusSdk() and its parameters googlePlusFieldsMapping and permissions.
As far as I understand, when the user logs in, you fetch Google user data via OpenId Connect, is that right? There is almost every data I need, but I would like to store user photo and birthday as well and I can’t find any corresponding field for mapping these data into Backendless User table. What can I do here?
In your login example, you are sending an empty list of permissions when the user is about to log in, I’m wondering when must we send a populated list of permissions and is there some example how to do that?
My code so far:
private void handleAccessTokenInBackendless(String idToken, String accessToken ) {
Log.d(LOG_TAG, "idToken: " + idToken + ", accessToken: " + accessToken);
Map<String, String> googlePlusFieldsMapping = new HashMap<>();
googlePlusFieldsMapping.put("given_name", "first_name");
googlePlusFieldsMapping.put("family_name", "last_name");
googlePlusFieldsMapping.put("gender", "gender");
googlePlusFieldsMapping.put("email", "email");
googlePlusFieldsMapping.put("birthday", "birthday");
googlePlusFieldsMapping.put("imageUri", "image_uri");
List<String> permissions = new ArrayList<>();
if (idToken != null && accessToken != null) {
Backendless.UserService.loginWithGooglePlusSdk(idToken, accessToken, googlePlusFieldsMapping, permissions, new AsyncCallback<BackendlessUser>() {
@Override
public void handleResponse(BackendlessUser backendlessUser) {
Log.i(LOG_TAG, "Logged in to backendless, user id is: " + backendlessUser.getObjectId());
}
@Override
public void handleFault(BackendlessFault backendlessFault) {
Log.e(LOG_TAG, "Could not login to backendless: " + backendlessFault.getMessage() + " code: " + backendlessFault.getCode());
}
});
}
}
Regards