android – Firebase令牌身份验证错误

前端之家收集整理的这篇文章主要介绍了android – Firebase令牌身份验证错误前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
我正在使用firebase存储来上传文件,但是当我上传时,我收到此错误
E/StorageUtil: error getting token java.util.concurrent.ExecutionException: com.google.android.gms.internal.zzand: Please sign in before trying to get a token.

我用谷歌搜索但无法得到答案!
我已经登录了firebase.

解决方法

我认为您在上传文件之前没有签名.在启动器活动的onCreate()中,尝试此代码
FirebaseAuth mAuth = FirebaseAuth.getInstance();

然后在onStart()中,

FirebaseUser user = mAuth.getCurrentUser();
if (user != null) {
  // do your stuff
} else {
  signInAnonymously();
}

signInAnonymously()

private void signInAnonymously() {
    mAuth.signInAnonymously().addOnSuccessListener(this,new  OnSuccessListener<AuthResult>() {
            @Override
            public void onSuccess(AuthResult authResult) {
                // do your stuff
            }
        })
        .addOnFailureListener(this,new OnFailureListener() {
            @Override
            public void onFailure(@NonNull Exception exception) {
                Log.e(TAG,"signInAnonymously:FAILURE",exception);
            }
        });
}

这可以解决您的问题

原文链接:https://www.f2er.com/android/317357.html

猜你在找的Android相关文章