I have different users with specific roles. For example, lawyers can delete clients and admins can delete both lawyers and clients. However, as an admin user, I encounter a problem when trying to delete another user. This is because in order to obtain the idToken of another user for deletion, I must first login as that user. Since I am logged in as an admin, I only have my own idToken and not that of the other user. Can someone provide guidance on how to resolve this issue?
Here is what I have tried:
deleteUser(user: UserModel) {
this.http.delete(`${this.url}/Users/${user.FirebaseID}.json`).subscribe();
return this.http.post(`https://identitytoolkit.googleapis.com/v1/accounts:delete?key=${myKey}`,{"idToken":`${user.FirebaseID}`});
}
However, this approach results in an error stating "idToken Invalid" due to using the Firebase ID instead of the actual idToken. Is there a way to retrieve the idToken without having to login as the targeted user?