We have an app using both Google and Apple for social auth login. The USER object being returned by both is not consistent, is there a solution to making these return the same object structure? Also, the NAME field for Apple is returning the email, is this expected? The only way to get first and last name is to split the NICKNAME on “.”? I have attached a screen grab of the Google and Apple USER objects.
Hi @bniksa,
Welcome to the Auth0 Community!
I can confirm that user objects will vary depending on the connection type. The user object is dependent on how the IdP returns the info.
You can use Rules to manipulate this data after a successful login.
For example:
function (user, context, callback) {
if (context.connectionStrategy === "apple") {
const nameArr = user.name.split('@')[0].split('.');
user.name = `${nameArr[0]} ${nameArr[1]}`;
}
callback(null, user, context);
}
This will normalize the name
property from john.doe@gmail.com
to john doe
. This rule does not permanently change this property in the user profile, but simply normalizes what is returned after successful login.
Hope that helps!
It does not really help, what I want is a consistent way to get the users first and last name from Apple. What if my email was john.doe213@gmail.com