Open mauriceackel opened 3 years ago
For everyone who is interested, I solved this in the following way:
const { CapacitorFirebaseAuth } = Capacitor.Plugins;
const result = (await CapacitorFirebaseAuth?.signIn({
providerId: authProvider,
})) as AppleSignInResult;
const credential = new firebase.auth.OAuthProvider(
'apple.com',
).credential(result.idToken);
await user.reauthenticateWithCredential(credential);
This has to be adapted for other auth providers like google by changing the way the credential
is set.
It would be really nice to have this as a native function though 🙃🚀
@mauriceackel This is a life saver. But I can't for the life of me figure out how to modify it to work with provider Google. the GoogleAuthProvider() doesn't have .credential method... Any ideas?
Hi @farcondee and nice to hear that this is helping you out! I got this working for google auth with the following code:
const result = (await CapacitorFirebaseAuth?.signIn({
providerId: authProvider,
})) as GoogleSignInResult;
const credential = firebase.auth.GoogleAuthProvider.credential(
result.idToken,
);
await user.reauthenticateWithCredential(credential);
Hope this helps.
P.S.: I am using firebase ^8.4.2
@mauriceackel Thanks for the snippet. I noticed the issue I have is Xcode is throwing this error on the CapacitorFirebaseAuth.signIn step:
{"code":"auth/popup-blocked","message":"Unable to establish a connection with the popup. It may have been blocked by the browser."}
Sorry I can't help with that. For me it is working as shown
As described in the firebase docs, some actions require the user to be re-authenticated if the sign-in date is too old.
Is this library capable of offering this functionality? If not, are there plans to add this?