标签: firebase-authentication

登录时出现一些错误 PlatformException(ERROR_ADMIN_RESTRICTED_OPERATION, 此操作仅限管理员。, null)

我是 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;
    }
  }
}

Run Code Online (Sandbox Code Playgroud)

主文件:

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( …
Run Code Online (Sandbox Code Playgroud)

firebase firebase-authentication flutter

1
推荐指数
2
解决办法
1911
查看次数

无法在 org.gradle.api.Project 类型的项目“:app”上找到参数 [] 的方法 Properties()

我在 Android Studio 中更新 Flutter 后出现此错误,请帮助,我厌倦了升级和降级 Firebase Auth 依赖项 flutter doctor 命令显示没有错误,我也尝试更改类路径但没有成功,但是当我构建时,我总是收到此错误

FAILURE: Build failed with an exception.
[   +2 ms] * Where:
[        ] Build file 'C:\Users\Corsair\Desktop\Flutter_1_2\outdoor_1_2\android\app\build.gradle' line: 2
[        ] * What went wrong:
[        ] A problem occurred evaluating project ':app'.
[        ] > Could not find method Properties() for arguments [] on project ':app' of type org.gradle.api.Project.
[        ] * Try:
[        ] Run with --stacktrace option to get the stack trace. Run with --info or …
Run Code Online (Sandbox Code Playgroud)

dart firebase build.gradle firebase-authentication flutter

1
推荐指数
1
解决办法
4559
查看次数

如何在flutter中自动登录现有用户

我有 4 个屏幕:

1.有登录和注册两个按钮(main.dart)

2.登录界面。(检查用户是否通过身份验证,然后推送到主页)

3.注册屏幕。(创建用户并推送用户登录)

4.首页。(带注销按钮)

现在,我的问题是:

  1. 这是正确的方法吗?

  2. 我希望现有用户自动登录。(主要问题)我知道使用登录现有用户进行自动登录的概念。你能帮我吗?谢谢。

我想在 main.dart 中检查用户是否已通过身份验证,如果是,则推送到主页,否则显示 main.dart 本身中的登录页面。

main.dart


void main() => runApp(MyApp());

class MyApp extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      debugShowCheckedModeBanner: false,
      theme: ThemeData(
        primaryColor: Color.fromRGBO(255,188,114, 1),
      ),
      home: Loginpage (),
    );
  }
}

class Loginpage extends StatefulWidget{...}
class _LoginpageState extends State<Loginpage>{...}
Run Code Online (Sandbox Code Playgroud)

authentication dart firebase firebase-authentication flutter

1
推荐指数
1
解决办法
4689
查看次数

我可以将带有真实密码的 csv 导入 Firebase 身份验证吗

我想向 Firebase 身份验证项目添加多个预定义密码的用户

我知道它可以使用哈希密码来完成,但在我的情况下,我有真正的密码而不是生成的哈希密码

我可以用户firebase auth:import使用真实密码上传还是有任何方法可以使用我的项目哈希参数将真实密码转换为哈希密码?

例如

userdata.csv 样本

firebase firebase-authentication firebase-cli

1
推荐指数
1
解决办法
531
查看次数

使用 Firebase Cloud Functions 更新用户

我想通过电话号码查找用户并displayName使用 Admin SDK 在 Firebase Cloud Functions 中更新他们。例如,当我尝试运行此代码时:

import * as admin from 'firebase-admin'
admin.auth().getUserByPhoneNumber(phone).then((user) => {
   user.displayName = newName;
}).catch((reason) => console.log(reason['message']));
Run Code Online (Sandbox Code Playgroud)

我收到以下消息:

无法分配给对象“#UserRecord”的只读属性“displayName”

虽然我不明白这个例外,但我想不出不同的方法来做到这一点。任何的想法?

javascript firebase firebase-authentication google-cloud-functions firebase-admin

1
推荐指数
1
解决办法
645
查看次数

对管理员和普通用户使用相同身份验证方法时的用户冲突 | Firebase 身份验证

我正在处理一个 android 应用程序的管理模块。管理模块是一个基于 Angular 的网络应用程序。Firebase auth(Email/password) 用于以管理员身份登录。我已经向 firebase 添加了一个手动凭据条目,管理员正在使用这些凭据登录(因为管理员没有注册功能)

另一方面,Android 开发人员也使用相同的 Auth 方法来登录用户。因此,android 应用程序的用户可以使用他们的凭据登录到 Admin 模块。

如何防止 android 用户登录到 web 应用程序。是否有任何方法或规则可用于过滤传入的登录请求并仅当电子邮件属于 Admin 时才允许登录?

firebase firebase-security angularfire firebase-authentication

1
推荐指数
1
解决办法
297
查看次数

Firebase - 在管理员中设置自定义用户声明不起作用

我有一个 Firebase 云功能,可以对从给定电子邮件中找到的 Firebase 用户设置自定义声明。

这是函数代码:

export const addAdmin = functions.https.onRequest(async (request, response) => {
  // Setting policies
  response.set("Access-Control-Allow-Origin", "*");
  response.set("Access-Control-Allow-Methods", "POST");
  response.set("Access-Control-Allow-Headers", "Content-Type");

  try {
    let details = JSON.parse(request.body);
    let user = await admin.auth().getUserByEmail(details.email);

    if (details.master !== "************") throw Error("Wrong Password");

    admin
      .auth()
      .setCustomUserClaims(user.uid, { admin: true })
      .then(() => {
        response.send(
          `User with uid ${user.uid} was set with claims - ${JSON.stringify(
            user.customClaims
          )}`
        );
      })
      .catch(error => {
        console.error(error);
        response.status(400).send(error);
      });
  } catch (error) {
    console.error(error);
    response.status(400).send(error);
  } …
Run Code Online (Sandbox Code Playgroud)

node.js firebase firebase-authentication firebase-admin

1
推荐指数
1
解决办法
757
查看次数

允许读取访问 Firebase Firestore 中的一个特定集合

在我的 android 应用程序中,我使用 Firebase Firestore 存储一组“用户名”,以便在用户登录之前进行查询,以检查所选用户名是否可用。

目前我的项目有 2 个主要集合:“用户”和“用户名”。我试图仅在“用户名”集合中允许读取访问。我的程序失败,因为当我尝试在用户通过身份验证之前查询“用户名”集合时,它说我没有正确的权限。

我的规则非常基本,但我想知道是否可以以某种方式修改它们以使我的项目正常工作。规则如下:

rules_version = '2';
service cloud.firestore {
  match /databases/{database}/documents {
    match /{document=**} {
      allow read, write: if request.auth != null;
    }
  }
}
Run Code Online (Sandbox Code Playgroud)

firestore 数据库的视觉概念:

在此处输入图片说明

firebase firebase-security firebase-authentication google-cloud-firestore

1
推荐指数
1
解决办法
1471
查看次数

Flutter 中的 Facebook 登录错误:访问令牌错误:{"code":190,"message":"无效的 OAuth 访问令牌。"}],空)

我正在尝试在我的 flutter 应用程序上实现 Facebook Firebase 身份验证,

我已经解决了所有问题并且一切顺利,但是在 Facebook 要求用户提供登录凭据之后。它给了我这个错误:

PlatformException(ERROR_INVALID_CREDENTIAL, The supplied auth credential is malformed or has expired. [ Bad access token: {"code":190,"message":"Invalid OAuth access token."} ], null)
Run Code Online (Sandbox Code Playgroud)

这是我使用的代码:

PlatformException(ERROR_INVALID_CREDENTIAL, The supplied auth credential is malformed or has expired. [ Bad access token: {"code":190,"message":"Invalid OAuth access token."} ], null)
Run Code Online (Sandbox Code Playgroud)

这是我正在使用的软件包 pubspec.yaml

  Future faceBookSignIn() async {
    try{
      var result = await _facebookAuth.logIn(['email']);
      print(result.status.toString());
      if (result.status == FacebookLoginStatus.loggedIn){
        final AuthCredential credential = FacebookAuthProvider.getCredential(accessToken: result.accessToken.toString());
        AuthResult facebookResult = await _auth.signInWithCredential(credential);
        FirebaseUser facebookUser …
Run Code Online (Sandbox Code Playgroud)

android ios firebase firebase-authentication flutter

1
推荐指数
1
解决办法
587
查看次数

Flutter:MissingPluginException(在频道 plugins.flutter.io/firebase_auth 上找不到方法 createUserWithEmailAndPassword 的实现)

我正在为 android 设备从 flutter 设计一个聊天应用程序,但是当我添加一个用于 firebase 身份验证的插件时,它给出了以下异常。我正在接受你的回答。先感谢您!

Flutter: MissingPluginException(No implementation found for method createUserWithEmailAndPassword on channel plugins.flutter.io/firebase_auth)

这是注册屏幕中的代码

  class _RegistrationScreenState extends State<RegistrationScreen> {
  final _auth = FirebaseAuth.instance;
  String email;
  String password;
  .
  .
  .

  onPressed: () async{
          try {
            final newUser = await _auth.createUserWithEmailAndPassword(
                email: email, password: password);
            if(newUser!=null){
              Navigator.pushNamed(context, ChatScreen.id);
            }
             }catch(e){
              print(e);
          }
          },
Run Code Online (Sandbox Code Playgroud)

这是聊天屏幕中的代码

class _ChatScreenState extends State<ChatScreen> {
final _auth = FirebaseAuth.instance;
FirebaseUser loggedInUser;

@override
void initState(){
 super.initState();

getCurrentUser();
}

void getCurrentUser() async{

 try {
  final …
Run Code Online (Sandbox Code Playgroud)

android-studio firebase-authentication flutter

1
推荐指数
1
解决办法
3999
查看次数