![](/img/trans.png)
[英]Call from user 0 as user -1 without permission INTERACT_ACROSS_USERS or INTERACT_ACROSS_USERS_FULL not allowed
[英]How to interact with Firebase user after API call?
我使用 Retrofit2 執行 API 調用以使用電子郵件和密碼通過 Firebase 身份驗證登錄用戶,然后需要以某種方式與用戶對象進行交互,即刷新一些數據或檢查用戶是否在下次應用程序啟動時登錄(我得到了正確的 Json目的)。
但是在 API 調用檢查FirebaseAuth
對象mAuth.getCurrentUser()
給出null
並且不知道如何在我的應用程序中保存登錄狀態。
NetworkService.getInstance().getJsonApi()
.loginWithEmail(email, password, true)
.enqueue(new Callback<Transaction.Result>() {
@Override
public void onResponse(Call<Transaction.Result> call, Response<Transaction.Result> response) {
if (response.code() == 200) {
// Sign in success, update UI with the signed-in user's information
Log.d(TAG, "signInWithEmail:success");
FirebaseUser user = mAuth.getCurrentUser();
activity.updateUI(user);
activity.startService();
} else {
Log.d(TAG, "signInWithEmail:failure");
activity.showToast("Authentication failed.");
activity.updateUI(null);
}
activity.hideProgressBar();
}
@Override
public void onFailure(Call<Transaction.Result> call, Throwable t) {
t.printStackTrace();
}
});
如何正確檢索FirebaseUser
?
謝謝。
如果您使用 Firebase Auth REST API 登錄用戶,則不能同時使用 Firebase Auth SDK 管理該登錄。 您必須堅持使用 REST API 進行所有管理。 這意味着您必須跟蹤從 API 獲得的 ID 令牌,在令牌過期前每小時刷新一次,並保持自己對用戶“登錄”意味着什么的認識。
我強烈建議只使用提供的 SDK,因為它會自動為您完成所有這些。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.