【问题标题】:Can i set a custom uid in firebase anonymous auth with java?我可以使用java在firebase匿名身份验证中设置自定义uid吗?
【发布时间】:2018-03-08 00:11:54
【问题描述】:

我正在匿名身份验证以访问 firebase,但我希望自分配的 UID 符合我定义的标准,然后我留下我使用的匿名身份验证代码:

auth.signInAnonymously()
        .addOnCompleteListener(task -> {
            if (task.isSuccessful()) {


                mUsername = idChat.substring(0, 10);
                id = task.getResult()
                        .getUser()
                        .getUid();
                isLoggedIn = true;
                mPhotoUrl = "";
                initAdapter();
            }
        })
        .addOnFailureListener(task -> displayError(task.getMessage()));

【问题讨论】:

    标签: java firebase firebase-authentication firebase-security


    【解决方案1】:

    不,你不能。您可以使用 Firebase Anonymous Authentication 创建和使用临时匿名帐户向 Firebase 进行身份验证。请注意,如果匿名用户决定稍后注册您的应用,您可以将他们的登录凭据链接到匿名帐户,以便他们可以在以后的会话中继续使用受保护的数据。

    用户可以通过相同的 Firebase user ID 识别,而不管他们用于登录的身份验证提供程序(Anonymous AuthenticationUser/PaaswordGoogle accountFacebook account 等等)。

    所以自定义 id 是由 Firebase 生成的,不可能按照您的方式设置自定义 uid。

    【讨论】:

    • 哦!好的,我更改身份验证或创建后端以使用自定义令牌 Ty @Alex
    • 其实可以,只是需要在 Firebase 上下功夫,不知道值不值得。
    猜你喜欢
    • 1970-01-01
    • 2017-07-11
    • 2016-10-18
    • 1970-01-01
    • 2016-10-14
    • 1970-01-01
    • 2020-04-01
    • 2022-12-10
    • 2020-09-10
    相关资源
    最近更新 更多