【问题标题】:Firebase doesn't return userFirebase 不返回用户
【发布时间】:2021-01-28 16:17:07
【问题描述】:

我有一个与 Firebase 交互的 AuthService 类。然后在 Signin.dart 中,我想获取该用户,但每次获取用户时遇到问题。我收到错误消息,显示 Firebase 无法发送用户。

错误:

发生了异常。平台异常 (平台异常(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% 自动 0;最大宽度:390 像素;最小高度:180 像素;填充:30 像素 0 15 像素}* > 正文{background:url(//www.google.com/images/errors/robot.png) 100% 5px 无重复;padding-right:205px}p{margin:11px 0 22px;overflow:hidden}ins{color:#777;text-decoration:none}a img{border:0}@media 屏幕和 (max-width:772px){body{background:none;margin-top:0;max-width:none;padding-right:0}}#logo{background:url(//www.google.com/images/品牌/googlelogo/1x/googlelogo_color_150x54dp.png) no-repeat;margin-left:-5px}@media 仅屏幕和 (最小分辨率: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) 不重复;-webkit-背景大小:100% 100%}}#logo{display:inline-block;height:54px;width:150px}

403. 这是一个错误。

您的客户没有 有权获取 URL /identitytoolkit/v3/relyingparty/signupNewUser从这里 服务器。我们知道的就这些。 ], {}, 空值))

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")),
      ),
    );
  }
}

【问题讨论】:

  • 您是否将 firbase 正确连接到您的 Flutter 项目?
  • 是的,这不是我第一次这样做。好纠结

标签: firebase flutter dart firebase-authentication


【解决方案1】:

google-service.jsonbuild.gradle 文件中检查您的项目的ID 必须相同。

【讨论】:

  • 我不知道为什么,一个小时后它没有任何变化???
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 2014-12-16
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多