You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Google内部测试发布后Firebase Auth出现未知自动生成账号求助

问题解答

陌生账号的来源

这些账号是**Google Play预发布报告(Pre-launch Report)**自动生成的测试账号。Google针对发布到内部/封闭测试渠道的应用,会启动自动化测试流程,用虚拟Google账号登录应用检测功能(比如你的Google登录集成、订阅功能),这些账号就是测试过程中自动创建的。

阻止方法

  • 关闭预发布报告功能:
    登录Google Play控制台进入你的应用页面,导航到「测试」>「预发布报告」,找到「启用预发布报告」选项并关闭。注意:关闭后会失去自动化测试相关报告,若需要可后续再开启。
  • 限制Firebase Auth登录范围:
    在Firebase控制台「Authentication」>「登录方法」中,针对Google登录设置「授权域」,只允许内部测试人员的邮箱域名;或者添加测试人员邮箱白名单。也可以通过Firebase安全规则限制仅指定邮箱用户能创建账号:
    rules_version = '2';
    service cloud.firestore {
      match /databases/{database}/documents {
        match /users/{userId} {
          allow create: if request.auth.token.email in ['test1@example.com', 'test2@example.com'];
        }
      }
    }
    

拦截同步到Firestore的方法

  • 用Firebase云函数拦截:
    创建onCreate触发器的云函数,新用户创建时检查是否在测试人员名单内,不在则删除Auth账号并阻止同步:
    const functions = require("firebase-functions");
    const admin = require("firebase-admin");
    admin.initializeApp();
    
    exports.blockUnauthorizedUsers = functions.auth.user().onCreate(async (user) => {
      const allowedEmails = ["test1@example.com", "test2@example.com"]; // 替换为你的测试人员邮箱
      if (!allowedEmails.includes(user.email)) {
        await admin.auth().deleteUser(user.uid);
        functions.logger.log(`Deleted unauthorized user: ${user.email}`);
      }
    });
    
  • 应用端添加校验逻辑:
    用户登录成功后,先对比本地存储的测试人员名单,若不在名单内则引导退出,并调用Firebase Auth接口删除该账号。

清除已存在的陌生账号

直接在Firebase控制台「Authentication」>「用户」页面,批量选中陌生账号删除即可。

内容的提问来源于stack exchange,提问作者Gregor Sotošek

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.08.03 14:15:32