标签: firebase-authentication

在Android应用中使用Firebase(BaaS)存储电子邮件和密码时,如何包含用户名?

Firebase createUser()方法需要一个电子邮件和密码字段,但是如果我还想让用户使用类似于Snapchat,Instagram,StackOverflow等的自定义用户名呢?是否有任何方法可以修改现有方法以接受该字段,或者我是否需要手动推送和管理此信息,如果是这样的话?

这是我第一次尝试存储所需的用户信息:

Firebase ref = new Firebase(firebaseURL);
ref.createUser(email, password, new Firebase.ValueResultHandler<Map<String, Object>>() {
@Override
public void onSuccess(Map<String, Object> result) {
System.out.println("Successfully created user account with uid: " + result.get("uid"));

//Sign user in
Firebase ref = new Firebase(firebaseURL);
ref.authWithPassword(email, password, new Firebase.AuthResultHandler() {

@Override
public void onAuthenticated(AuthData authData) {
System.out.println("User ID: " + authData.getUid() + ", Provider: " + authData.getProvider());

//Save user info
Firebase userRef = new Firebase(firebaseURL + "Users/");
User user = new User(username, authData.getUid());
userRef.setValue(user);
Run Code Online (Sandbox Code Playgroud)

这是好习惯吗?我想用存储用户名的UID可以帮助我将来处理更改等.另外,我应该实现updateChildren() …

android firebase firebase-authentication firebase-realtime-database

23
推荐指数
2
解决办法
4万
查看次数

从Android应用程序正确注销用户

我正在开发一个小型Android应用程序,基本上到目前为止它只具有登录和注销功能.我正在使用Firebase来存储用户数据以及身份验证.

所以我登录工作并且它应该对用户进行身份验证,并且我已经注销了unauthenticates用户的意义.但是在应用程序中有什么我必须做的才能杀死会话吗?

if (id == R.id.action_log_out) {
    ref.unauth(); //End user session
    startActivity(new Intent(MainActivity.this, LoginActivity.class)); //Go back to home page
    finish();
}        
Run Code Online (Sandbox Code Playgroud)

我觉得这会起作用吗?显然,如果有人退出,他们应该无法点击后退按钮并神奇地返回到最后一页而不重新登录.

android firebase firebase-authentication

23
推荐指数
3
解决办法
4万
查看次数

如何将Firebase数据库锁定到特定(电子邮件)域中的任何用户?

我有一个使用Firebase数据库的小型个人Firebase webapp.我想从单个特定域向任何用户保护(锁定)此应用程序.我想通过Google进行身份验证.我不清楚如何配置规则来说"只有来自单个特定域(例如@foobar.com)的用户才能读写这个数据库".

(我看到的部分问题:使用足够的信息来引导数据库很难使这个用例工作.我需要在验证时知道用户的电子邮件,但auth对象不包含电子邮件.它似乎是鸡蛋问题,因为我需要编写引用数据库中数据的Firebase规则,但由于我的用户无法写入数据库,因此该数据尚不存在.)

如果auth有电子邮件,那么我可以轻松地编写规则.

提前致谢!

firebase firebase-security firebase-authentication firebase-realtime-database

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

如何在Spring Boot REST应用程序中使用Firebase?

我有一个Spring Boot REST应用程序,它依赖于在Firebase中完成的身份验证.在客户端,Firebase会生成一个令牌,在Spring Boot中,我需要验证uid.但我注意到代码处于回调模式,那么如何实现Spring Boot功能以便完成任务呢?

    @RequestMapping(value = "/api/restCall", method = RequestMethod.POST, consumes = "application/json", produces = "application/json")
    public Object restCall(@RequestBody Parameters requestBody) throws Exception {

    // idToken comes from the client app (shown above)
        String idToken = requestBody.getToken();

        Task<FirebaseToken> task = FirebaseAuth.getInstance().verifyIdToken(idToken)
            .addOnSuccessListener(new OnSuccessListener<FirebaseToken>() {
                @Override
                public void onSuccess(FirebaseToken decodedToken) {
                    String uid = decodedToken.getUid();
                    // process the code here
                }
        }); 
        // how do I return here, since the code is in the onSuccess?
        // do I return as …
Run Code Online (Sandbox Code Playgroud)

java rest firebase spring-boot firebase-authentication

23
推荐指数
2
解决办法
4万
查看次数

Firebase托管 - 密码保护网站?

我刚刚将一个网站部署到Firebase托管,它运行良好 - 设置非常简单.

不过,我的问题是,有什么方法可以通过身份验证访问网站吗?这是一个只有我的团队才能访问的管理面板.有什么办法可以密码保护我的Firebase托管网站或将其私有化吗?

谢谢!

web firebase firebase-hosting firebase-authentication

23
推荐指数
2
解决办法
3806
查看次数

AngularJS错误:TypeError:v2.login不是函数

我想在单击登录按钮时调用登录功能,但不断在标题中收到错误消息.有人可以在我的脚本中指出错误吗?

login.js代码如下:

/*global Firebase, angular, console*/

'use strict';
// Create a new app with the AngularFire module
var app = angular.module("runsheetApp");

app.controller("AuthCtrl", function ($scope, $firebaseAuth) {
    var ref = new Firebase("https://xxxxx.firebaseio.com");
    function login() {
        ref.authWithPassword({
            email    : "xxxxx",
            password : "xxxx"
        }, function (error, authData) {
            if (error) {
                console.log("Login Failed!", error);
            } else {
                console.log("Authenticated successfully with payload:", authData);
            }
        });
    }
});
Run Code Online (Sandbox Code Playgroud)
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.2.21/angular.min.js"></script>
Run Code Online (Sandbox Code Playgroud)

login.html的代码如下:

<div class="container" style="max-width: 300px">
    <form class="form-signin">       
      <h2 class="form-signin-heading" style="text-align: center">Please Sign In</h2>
      <input …
Run Code Online (Sandbox Code Playgroud)

angularjs firebase angularjs-ng-click firebase-authentication

22
推荐指数
5
解决办法
4万
查看次数

Firebase使用Google帐户覆盖登录

在文档中似乎没有提到这一点,我发现的只有这个这个,我想在此证实:

如果现有帐户具有相同的电子邮件地址但使用其他凭据(例如密码或不可信提供商)创建,则出于安全原因,将删除先前的凭据.

如果用户通过Facebook或电子邮件/密码登录,稍后通过Google登录,则他们的帐户登录方式将转换为Google.它只发生在Google上,并且只有一个帐户的设置才有效.

它是否应该是这样的,有什么办法可以阻止它吗?

android facebook firebase firebase-authentication google-signin

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

"此应用未授权在模拟器中使用Firebase身份验证"

当我尝试在模拟器上运行我的应用程序时,我收到此错误.

我做了什么:

  1. 我正在使用Firebase-UI并运行Android O.
  2. 我更新了Play商店.
  3. 我已将所有SHA-1代码添加到Firebase控制台,并且包名称匹配.

事实上,当我在真实设备上运行应用程序时,它运行完美,我可以登录.

This app is not authorized to use Firebase Authentication. Please verify that the correct package name and SHA-1 are configured in the Firebase Console.
 com.google.firebase.auth.FirebaseAuthException: This app is not authorized to use Firebase Authentication. Please verifythat the correct package name and SHA-1 are configured in the Firebase Console. [ App validation failed. Is app running on a physical device? ]
 at com.google.android.gms.internal.jz.zzK(Unknown Source:239)
 at com.google.android.gms.internal.kp.zza(Unknown Source:2)
 at com.google.android.gms.internal.kq.run(Unknown Source:37)
 at android.os.Handler.handleCallback(Handler.java:789)
 at android.os.Handler.dispatchMessage(Handler.java:98) …
Run Code Online (Sandbox Code Playgroud)

android firebase firebase-authentication firebaseui

22
推荐指数
6
解决办法
3万
查看次数

将Firebase Auth用户映射到Firestore文档

我正在尝试使用FirebaseFirestore数据库User在我的Android应用中处理s.

最初我想使用从包返回的idAuth(字符串),并将其设置为users Collection数据库中的id .在创建Document内部时Collection users,我将uid字段设置为该auth包字符串.

我意识到没有办法将该字符串设置为可索引值,以便查询如下:

// get Auth package uid string
db.collection("users").document(auth_uid_string);
Run Code Online (Sandbox Code Playgroud)

会工作.

所以替代方案,我想,是使用Query.whereEqualTo("uid", auth_uid_string)哪个会给我列表中的用户,因为firestore不认为查询是针对唯一值的.

我想避免上述解决方案,并设计一种方法来存储users应用程序firestore,并使用该auth包来验证我是否获取了正确的用户.这样的解决方案是否可行?或者我应该尝试不同的 firebase服务,甚至只是在heroku中运行postgres服务器?

user-management firebase firebase-authentication google-cloud-firestore

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

通过 Firebase 使用 Google 登录时,“ApiExpception: 7”是什么意思?

在 Flutter 中尝试通过 Firebase 身份验证使用 Google 登录时,出现错误:

flutter com.google.android.gms.common.api.apiexception: 7
Run Code Online (Sandbox Code Playgroud)

我没有在任何地方找到这个问题的任何解决方案。这是什么意思?

firebase-authentication google-signin flutter

22
推荐指数
2
解决办法
5711
查看次数