Firebase 登录PlatformException时出现一些错误(错误\u ADMIN\u RESTRICTED\u操作,此操作仅限于管理员,null)

Firebase 登录PlatformException时出现一些错误(错误\u ADMIN\u RESTRICTED\u操作,此操作仅限于管理员,null),firebase,flutter,firebase-authentication,Firebase,Flutter,Firebase Authentication,我是firebase的新手,我尝试使用firebase的匿名身份验证对用户进行身份验证,但它给出了以下错误 示例代码如下所示: 验证dart文件 class AuthServices { final FirebaseAuth _auth = FirebaseAuth.instance; //sign in method. Future signningAnon() async { try { AuthResult result = await _auth.si

我是firebase的新手,我尝试使用firebase的匿名身份验证对用户进行身份验证,但它给出了以下错误

示例代码如下所示:

验证dart文件

class AuthServices {
  final FirebaseAuth _auth = FirebaseAuth.instance;

  //sign in method.
  Future signningAnon() async {
    try {
      AuthResult result = await _auth.signInAnonymously();
      FirebaseUser user = result.user;
      return user;
    } catch (e) {
      print("There is some error while singing $e");
      return null;
    }
  }
}

主文件:

void main() {
  AuthServices _auth = AuthServices();
  runApp(MaterialApp(
    title: 'chekcing firbase authentication',
    home: Scaffold(
      backgroundColor: Colors.blueAccent,
        appBar: AppBar(
          title: Text("Firbase authentication"),
        ),
        body: Center(
          child: RaisedButton(
            color: Colors.white,
            child: Text('click me'),
            onPressed: () async{
              print("object");
              dynamic result = await _auth.signningAnon();
              print('result is $result');
            },
          ),
        )),
  ));
}
这是yaml依赖项文件

dependencies:
  flutter:
    sdk: flutter
    


  # The following adds the Cupertino Icons font to your application.
  # Use with the CupertinoIcons class for iOS style icons.
  cupertino_icons: ^0.1.2
  toast: ^0.1.5
  rflutter_alert: ^1.0.3
  timeline_list: ^0.0.3
  font_awesome_flutter: ^8.5.0
  carousel_slider: ^1.3.1
  photo_view: ^0.8.0
  url_launcher: ^5.4.1
  get_it: ^3.1.0
  flutter_compass: ^0.3.4
  firebase_auth: ^0.15.3 // here is firebase dependency.
  cloud_firestore: ^0.13.0+1


如果有人有解决方案,请提供帮助。

您需要在控制台的Firebase身份验证部分添加匿名登录选项。安装项目的位置。

需要在firebase身份验证中启用匿名登录方法。

需要启用匿名登录提供程序

  • 去消防基地
  • 转到身份验证
  • 启用匿名

  • 代码在哪里?能否编辑您的问题以包含准确的错误消息和堆栈跟踪?我有相同的错误。仍然找不到答案谢谢你的回答和宝贵的时间。我已经决定it@sagarkumar如果成功,请将其标记为正确答案/投票,以便您可以帮助其他人您需要在firebase控制台的“身份验证”部分启用它。根据平台的不同,按照入门说明进行操作。