firebase - Firebase 不返回用户
问题描述
我有一个与 Firebase 交互的 AuthService 类。然后在 Signin.dart 中,我想获取该用户,但每次获取用户时遇到问题。我收到错误消息,显示 Firebase can't send the user 。
错误:
发生异常。PlatformException(PlatformException(firebase_auth,com.google.firebase.FirebaseException:发生内部错误。[错误 403(禁止)!!1
*{margin:0;padding:0}html,code{font:15px/22px arial,sans-serif}html{background:#fff;color:#222;padding:15px}body{margin:7% auto 0; max-width:390px;min-height:180px;padding:30px 0 15px}* > body{background:url(//www.google.com/images/errors/robot.png) 100% 5px no-repeat;padding -right:205px}p{margin:11px 0 22px;overflow:hidden}ins{color:#777;text-decoration:none}a img{border:0}@media screen and (max-width:772px){body {background:none;margin-top:0;max-width:none;padding-right:0}}#logo{background:url(//www.google.com/images/branding/googlelogo/1x/googlelogo_color_150x54dp.png ) no-repeat;margin-left:-5px}@media only screen and (min-resolution:192dpi){#logo{background:url(//www.google.com/images/branding/googlelogo/2x/googlelogo_color_150x54dp. png) 不重复 0% 0%/100% 100%;-moz-border-image:url(//www.google.com/images/branding/googlelogo/2x/googlelogo_color_150x54dp.png) 0}}@media 仅屏幕和 (-webkit-min-device-pixel-ratio:2){#logo{background:url(//www.google. com/images/branding/googlelogo/2x/googlelogo_color_150x54dp.png) no-repeat;-webkit-background-size:100% 100%}}#logo{display:inline-block;height:54px;width:150px}403.这是一个错误。
您的客户端无权
/identitytoolkit/v3/relyingparty/signupNewUser
从此服务器获取 URL。我们知道的就这些。], {}, 无效的))
import 'package:firebase_auth/firebase_auth.dart';
class AuthService {
final FirebaseAuth _auth = FirebaseAuth.instance;
// sign in anon
Future signInAnon() async {
try {
UserCredential userCredential = await _auth.signInAnonymously();
User user = userCredential.user;
return user;
} catch (e) {
print(e.toString());
return null;
}
}
// sign in with email and password
// register with email and password
// sign out
}
登录.dart
import 'package:auth_flutter_coffe/Services/Auth.dart';
import 'package:flutter/material.dart';
class SignIn extends StatefulWidget {
@override
_SignInState createState() => _SignInState();
}
class _SignInState extends State<SignIn> {
final AuthService _auth = AuthService();
@override
Widget build(BuildContext context) {
return Scaffold(
backgroundColor: Colors.brown[700],
appBar: AppBar(
title: Text("SignIn"),
centerTitle: true,
backgroundColor: Colors.brown[900],
),
body: Container(
padding: EdgeInsets.symmetric(horizontal: 50.0, vertical: 50.0),
child: RaisedButton.icon(
onPressed: () async {
dynamic result = await _auth.signInAnon();
if (result == null) {
print("You Have to be SignIn");
} else {
print("SignIn");
print(result);
}
},
icon: Icon(Icons.transit_enterexit),
label: Text("SignIn")),
),
);
}
}
解决方案
检查您的项目的 idgoogle-service.json
和build.gradle
文件必须相同。
推荐阅读
- scala - 为什么用模式匹配收集不能缩小特定的类?
- c++ - 模板化特殊成员 (operator=) 的重载决议
- gmail - Google GMail API - users.messages.import() 不在收件箱中 为什么?
- node.js - 如何在基于 ElasticSearch 的系统上实现 ACL?
- flutter - 向 setState 添加回调而不只是在没有回调的情况下调用 setState 有什么意义?
- excel - 无法使用 excel 宏与 HP ALM 12.53 建立连接
- ruby-on-rails - rails - active admin - PG::InvalidColumnReference: ERROR: SELECT DISTINCT ON 表达式必须匹配初始 ORDER BY 表达式
- php - 如何使用 preg_split 得到期望的结果
- node.js - 当服务器在 Angular 中运行时从资产加载新图像
- php - 计算某一天的所有元素