My app has two authentication methods via Firebase Auth: Google and Facebook.
For Google, I had to regenerate the access token by performing a silent sign-in when I wanted to delete the user account from Firebase Auth:
val gso = GoogleSignInOptions.Builder(GoogleSignInOptions.DEFAULT_SIGN_IN)
.requestIdToken(getString(com.firebase.ui.auth.R.string.default_web_client_id))
.requestEmail()
.build()
val googleSignInClient = GoogleSignIn.getClient(requireActivity(), gso).silentSignIn()
googleSignInClient.addOnCompleteListener { task ->
try {
// Google Sign In was successful, authenticate with Firebase
val account = task.getResult(ApiException::class.java)
val credential = GoogleAuthProvider.getCredential(account.idToken!!, null)
} catch (e: ApiException) {
Toast.makeText(
requireActivity(),
"${e.message}",
Toast.LENGTH_LONG
).show()
}
}
I'm assuming I need to do the same for Facebook auth as well. How do I refresh/regenerate the Facebook Login token so that I can successfully delete a Facebook user from Firebase Auth?