Mauricio Silvestre
Mauricio Silvestre

Reputation: 311

Sync firebase auth data

When a create a new firebase auth user using facebook or google, I received the user email and name but when I create a anonymous user and convert it to a facebook user the name still empty. How I to to sync the data from facebook or google in every new login?

Thanks in advance.

AskFirebase

Upvotes: 0

Views: 271

Answers (1)

bojeil
bojeil

Reputation: 30858

Just use the updateProfile API. Here is an example with web on how to update the display name to the one in the provider data (assuming Facebook):

firebase.auth().currentUser.updateProfile({
  displayName: firebase.auth().currentUser.providerData[0].displayName
}).then(function() {
  // Display name updated successfully.
}).catch(function(error) {
  // error occurred.
});

To learn more about this API, refer to the Firebase references.

Upvotes: 2

Related Questions