public async void Get() { PrivateKeyModel privateKey = new PrivateKeyModel() { AuthProviderX509CertUrl = Constants.AuthProviderX509CertUrl, AuthUri = Constants.AuthUri, ClientEmail = Constants.ClientEmail, ClientId = Constants.ClientId, ClientX509CertUrl = Constants.ClientX509CertUrl, PrivateKey = Constants.PrivateKey, PrivateKeyId = Constants.PrivateKeyId, ProjectId = Constants.ProjectId, TokenUri = Constants.TokenUri, Type = Constants.Type }; var privateKeyJson = JsonConvert.SerializeObject(privateKey); if (FirebaseApp.DefaultInstance == null) { FirebaseApp.Create(new AppOptions() { Credential = GoogleCredential.FromJson(privateKeyJson) }); } // Start listing users from the beginning, 1000 at a time. var pagedEnumerable = FirebaseAuth.DefaultInstance.ListUsersAsync(null); var responses = pagedEnumerable.AsRawResponses().GetAsyncEnumerator(); while (await responses.MoveNextAsync()) { ExportedUserRecords response = responses.Current; foreach (ExportedUserRecord user in response.Users) { if (user.CustomClaims.ContainsKey("Role")) { FirebaseUsers.Add( new FirebaseUserModel { UId = user.Uid, DisplayName = user.DisplayName, Email = user.Email, Role = user?.CustomClaims["Role"]?.ToString(), EmailVerified = user.EmailVerified } ); } else { FirebaseUsers.Add( new FirebaseUserModel { UId = user.Uid, DisplayName = user.DisplayName, Email = user.Email, EmailVerified = user.EmailVerified } ); } } } }
public void Clear() { FirebaseUsers?.Clear(); }