2👍
✅
You can just call linkWithRedirect
on the anonymous user.
// Assuming you previously signed in anonymously.
firebase.auth().signInAnonymously().then(function(result) {
var provider = new firebase.auth.GoogleAuthProvider();
// Page will redirect to google and then back. You can get back
// result via getRedirectResult().
return firebase.auth().currentUser.linkWithRedirect(provider);
}).catch(function(error) {
// Error occurred.
});
Source:stackexchange.com