firebase - 登录时出现一些错误 PlatformException(ERROR_ADMIN_RESTRICTED_OPERATION, 此操作仅限管理员使用。, null)
问题描述
我是firebase的新手,我试图通过使用firebase的匿名身份验证来验证用户,但它给出了以下错误。
示例代码在这里:
验证飞镖文件。
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 身份验证部分添加匿名登录选项。您在哪里设置了项目。
推荐阅读
- sql - 如何更改要插入的条目的主键的值?
- c# - 使用 Visual Studio 2019 对 BizTalk 2020 工件进行单元测试会导致 Intellisense 问题
- java - 使用 JAVA 异步运行 gremlin 查询时出现 OOM 错误
- amazon-web-services - AWS Firehose Lambda 转换处理错误
- html - 如何在 HTML 中创建动态/灵活的文件/文件夹路径?
- javascript - 从数组中提取属性
- javascript - 在单个daterangepicker jquery中设置年份范围
- web - 我需要多久让谷歌抓取我的网站?
- c# - 索引超出了 c# 中 Threadpool 中的数组范围
- javascript - 如何使用 componentDidMount 和 Async 将输入条目保存在 API 调用的组件状态中?