【问题标题】:com.google.firebase.FirebaseException: An internal error has occurred. [ null ]com.google.firebase.FirebaseException:发生内部错误。 [ 空值 ]
【发布时间】:2018-09-20 18:55:02
【问题描述】:

帮助我想使用 firebase 使用自定义 firebase 令牌对我的应用程序进行身份验证,但是当创建令牌并发送到我的应用程序时,firebase 无法验证我的令牌并抛出

com.google.firebase.FirebaseException:发生内部错误。 [空]

网络服务代码

            FirebaseAuth.getInstance(instancePatient).createCustomToken(uid2, additionalClaims)
                    .addOnSuccessListener(new OnSuccessListener<String>() {
                        @Override
                        public void onSuccess(String customToken) {
                            str.setResponse(customToken);
                            System.out.println(customToken);
                        }
                    });

我的应用代码

    FirebaseAuth mAuth = FirebaseAuth.getInstance();
    mAuth.signInWithCustomToken(userString)
            .addOnCompleteListener(activity, new OnCompleteListener<AuthResult>() {
                @Override
                public void onComplete(@NonNull Task<AuthResult> task) {
                    if (!task.isSuccessful()) {
                        try{
                            throw task.getException();
                        }
                        catch (IllegalStateException e){
                            System.out.println(e.getMessage());
                        }
                        catch(RuntimeExecutionException e){
                            System.out.println(e.getMessage());
                        }
                        catch(FirebaseNetworkException e ){
                            System.out.println(e);
                        }
                        catch(FirebaseAuthException e){
                            System.out.println(e);
                        }
                        catch(Exception e){
                            System.out.println(e.getMessage());
                        }
                        listener.onSignInWithCustomTokenFailed(task);
                    }
                    else
                    {......
                    }
                }
            }

希望大家能听懂我的英文。

【问题讨论】:

  • 检查您是否将google-services.json 正确添加到您的项目中。转到您的firebase condole,而不是打开应用程序设置需要google-services.json,并且包应该与您的应用程序包名称匹配

标签: android firebase firebase-authentication


【解决方案1】:

好吧,事实证明从 createCustomToken 中删除 additionalClaims 可以解决问题。这是因为我在附加声明中输入了一个无效的字符串

【讨论】:

    猜你喜欢
    • 2017-04-28
    • 2020-01-19
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2018-10-31
    • 2017-06-24
    • 2018-11-30
    相关资源
    最近更新 更多