Hey Arnaud,
The error will contain the credential.
firebase.auth().currentUser.linkWithPopup(provider)
.catch(function(error) {
if (error.code == 'auth/credential-already-in-use') {
// You can get the email from error.email and the credential from error.credential.
// In this case, you can directly sign in with that credential without having to call signInWithPopup again.
// One option here is to initialize another FirebaseApp, sign in with this credential,
// merge both users and then sign in again in the original auth instance after both users are merged.
} else {
...
}
});
Best regards,
Bassam