I just implemented the possibility to delete the personal account at Firebase of an Android application. I then discovered that the application is still listed on the Google account with having access rights even though the Firebase account is already deleted.
CodePudding user response:
If you have implemented the option to sign in your users to Firebase with Google, then most likely you already have followed these steps:
According to:
I just implemented the possibility to delete the personal account at Firebase of an Android application.
If you have only deleted the Firebase authentication account it doesn't mean that everything related to Google is wiped out, because it's not.
To achieve what you want, I recommend you follow the below steps in the exact order I have added:
- Revoke Google access, using GoogleSignInClient#revokeAccess() method:
Revokes access given to the current application.
- Sign-out the user from Google using GoogleSignInClient#signOut() method.
Signs out the currently signed-in user if any.
- Delete the Firebase user account using FirebaseUser#delete() method:
Deletes the user record from your Firebase project's database. If the operation is successful, the user will be signed out.
- Delete all data in Cloud Firestore using DocumentReference#delete(), or the Realtime Database using DatabaseReference#removeValue(), if it exists.
So in the case of 3. there is no need to explicitly sign out the user from Firebase because when you delete the account, the user will be signed out automatically.
P.S. Please also remember that all four operations are asynchronous. So you need to wait until the operations are complete. In java, you can use a LiveData object and in Kotlin you can use Kotlin Coroutines.
Edit:
Please find below all the necessary docs:
So you'll be able to create a GoogleSignInOptions object and right after that a GoogleSignInClient object. Using the last one, you'll be able to sign out the user from Google, as mentioned above.
Regarding FirebaseUser#unlink(String provider) method, it only:
Detaches credentials from a given provider type from this user.