Firebase 令牌身份验证错误 [英] Firebase Token Authentication error

查看:50
本文介绍了Firebase 令牌身份验证错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用 firebase 存储上传文件,但在上传时出现此错误

I am using firebase storage to upload files , but when I upload I am getting this error

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 中登录.

I googled it but couldn't get answer for it! I have signed in, in firebase.

推荐答案

我想你在上传文件之前没有签名.在启动器活动的 onCreate() 中,试试这个代码

I think you didn't sign before uploading files. In onCreate() of launcher activity, try this code

FirebaseAuth mAuth = FirebaseAuth.getInstance(); 

然后在 onStart(),

Then in onStart(),

FirebaseUser user = mAuth.getCurrentUser();
if (user != null) {
  // do your stuff
} else {
  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);
            }
        });
}

这可能会解决您的问题

这篇关于Firebase 令牌身份验证错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆