0

I'm trying to run a script that will mark anonymous users with a flag in firestore. For that I'm getting all firebase auth users with firebase-admin's auth listUsers. But I'm not sure how to identify whether a user has an actual account using one of the providers or just signed-in anonymously. Via a firebase auth dashboard it's easy to see who is anonymous but not sure how to get that in code.

UserRecord objects returned from listUsers() have providerData array field. Each element has providerId So, my guess is I should somehow filter that based on whether a user has only one provider which is anonymous. Question is what is the providerId for anonymous auth? Didn't manage to find that in docs.

  • If I recall correctly, an anonymous user has no providers linked to it. Renaud's answer here seems to confirm that: https://stackoverflow.com/questions/55207090/how-do-you-tell-if-a-user-is-anonymous-in-the-oncreate-firebase-cloud-function, with links to sources. – Frank van Puffelen Jul 01 '22 at 03:39
  • Actually found the solution which worked for my case. Guess it might work for others as well if you allow to post it. – Daniil Andreyevich Baunov Jul 01 '22 at 04:24
  • 1
    Just checked - it's basically giving me the exact same results (whether user is anonymous) as displayed in firebase auth dashboard. So, seems accurate. – Daniil Andreyevich Baunov Jul 01 '22 at 04:33

0 Answers0