我不明白如何通過在存儲認證的價值... 下面是它試圖寫入文件時返回的錯誤,以及代碼本身的下方。 有沒有人遇到過這樣的問題?火力地堡認證+火力地堡貯存在Unity3d
權限規則使用標準
service firebase.storage {
match /b/project.appspot.com/o {
match /{allPaths=**} {
allow read, write: if request.auth != null;
}
}
}
System.AggregateException:類型 'System.AggregateException' 引發的異常。 ----------------- Firebase.Storage.StorageException:用戶沒有訪問此對象的權限。 ---> System.IO.IOException:本 服務器已終止內部異常 堆棧跟蹤的上載會話 - 完 -
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using Firebase;
using Firebase.Storage;
using Firebase.Auth;
public class Storage : MonoBehaviour {
public Texture2D texture;
public Auth autentification;
FirebaseApp app;
AppOptions options;
FirebaseStorage storage;
StorageReference storage_ref, ref_file;
// Use this for initialization
void Start() {
InitFirebase();
}
public void InitFirebase(){
print("InitFirebase start");
DependencyStatus dependencyStatus = FirebaseApp.CheckDependencies();
if (dependencyStatus != DependencyStatus.Available) {
FirebaseApp.FixDependenciesAsync().ContinueWith(task => {
dependencyStatus = FirebaseApp.CheckDependencies();
if (dependencyStatus == DependencyStatus.Available) {
Signin();
} else {
print("Could not resolve all dependencies: " + dependencyStatus);
}
});
} else {
Signin();
}
}
public void Signin(){
print("Signin start");
string _testEmail = "[email protected]";
string _testPassword = "qwerty";
options = new AppOptions();
options.ApiKey = "API_KEY";
options.StorageBucket = "STORAGE_BUCKET";
options.AppId = "APPID";
app = FirebaseApp.Create (options, "name");
FirebaseAuth.GetAuth(app).SignInWithEmailAndPasswordAsync (_testEmail, _testPassword).ContinueWith ((System.Threading.Tasks.Task<FirebaseUser> authTask) => {
if (authTask.IsCanceled) {
print("signin canceled");
} else if (authTask.IsFaulted) {
print("signin faulted " + authTask.Exception.ToString());
} else if (authTask.IsCompleted) {
print("signin complete , user id is " + authTask.Result.UserId);
storage = FirebaseStorage.GetInstance(app);
storage_ref = storage.GetReferenceFromUrl("gs://testproject-3b976.appspot.com/data/");
Upload ("images/" + texture.name + ".png");
} else {
print("signin unknown error");
}
});
}
我在Android上試過了,我有一切工作。謝謝您的幫助!與獨立的問題我也很感興趣,將等待答案:) –
你能用谷歌使用Firebase登錄? 我停留在獲取(串id_token,字符串的access_token)爲Firebase.Auth.GoogleAuthProvider.GetCredential方法。 請告訴我哪裏錯了? –