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

Firebase Auth请求OTP时触发internal-error内部错误求助

解决Firebase Auth Phone Provider发送OTP时的internal-error问题

排查与解决步骤:

  • 核对SHA证书指纹配置:
    进入Firebase控制台项目设置,确认Android平台的SHA-1和SHA-256指纹已正确添加。若近期重新生成签名密钥,需同步更新此处的指纹信息。

  • 检查手机号格式合规性:
    确保updatedMobileNumber严格遵循E.164标准,格式为+[国家码][手机号](例如+8613800138000),不能包含空格、短横线或其他特殊字符。

  • 更新Firebase依赖版本:
    执行flutter pub upgrade firebase_auth firebase_core,将firebase_auth及核心依赖升级至最新稳定版,旧版本可能存在引发内部错误的已知问题。

  • 查看Firebase控制台详细错误日志:
    登录Firebase控制台,进入「Authentication」→「Logs」,此处会展示比客户端日志更具体的错误原因,比如配额耗尽、API密钥限制、服务区域异常等。

  • 检查API密钥访问限制:
    在Firebase控制台「项目设置」→「常规」→「API密钥」中,确认对应API密钥未设置过严的限制规则。Web应用需确保允许当前域名请求;移动端无需设置HTTP referrer限制。

  • 验证Firebase Auth服务状态:
    确认Phone Auth服务无故障或维护情况,可通过Firebase官方状态页核查。

  • 重置API密钥:
    若怀疑API密钥配置异常,可在Firebase控制台重新生成密钥,并更新项目中的google-services.json(Android)或GoogleService-Info.plist(iOS)文件。


用户提供的报错日志:

flutter: exeption.credential: null
flutter: exeption.tenantId: null
flutter: exeption.phoneNumber: null
flutter: exeption.plugin: firebase_auth
flutter: exeption.code: internal-error
flutter: exeption.message: An internal error has occurred, print and inspect the error details for more information.
flutter: exeption.stackTrace: null

用户使用的代码片段:

await _firebaseAuth.verifyPhoneNumber(
        phoneNumber: updatedMobileNumber,
        verificationCompleted: (authCredential) {
          print("authCredential.smsCode: ${authCredential.smsCode}");
          // if (!otpAutoFill.isCompleted) {
          //   otpAutoFill.complete(authCredential.smsCode);
          // }
        },
        verificationFailed: (FirebaseAuthException exeption) {
          print("exeption.credential: ${exeption.credential}");
          print("exeption.tenantId: ${exeption.tenantId}");
          print("exeption.phoneNumber: ${exeption.phoneNumber}");
          print("exeption.plugin: ${exeption.plugin}");
          print("exeption.code: ${exeption.code}");
          print("exeption.message: ${exeption.message}");
          print("exeption.stackTrace: ${exeption.stackTrace}");

          _verifyPhoneException = exeption;
          if (!completer!.isCompleted) completer!.complete(false);
        },
        codeSent: (verificationCode, [code]) {
          _verificationCode = verificationCode;
          if (!completer!.isCompleted) completer!.complete(true);
        },
        codeAutoRetrievalTimeout: (verificationCode) {
          _verificationCode = verificationCode;
          if (!completer!.isCompleted) completer!.complete(true);
        },
);

内容的提问来源于stack exchange,提问作者Anshuman Sharma

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.06.16 15:01:00