我不知道如何在存储中传递身份验证的值.下面是试图写入文件时返回的错误,以及代码本身下面的错误。有人遇到过这样的问题吗?
权限规则使用标准
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 = "test@gmail.com";
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");
}
});
}发布于 2017-01-23 03:45:36
使用UnitySDK的防火墙身份验证现在在UnityEditor上不起作用。(也是独立的)
https://github.com/firebase/quickstart-unity/issues/3
你只在UnityEditor上试过吗?它可能适用于iOS或安卓系统。
但是,我也在寻找使用Unity3D独立游戏中的Firebase身份验证的方法。
Using Firebase Authentication with Unity on standalone game
如果你已经在iOS或安卓上试过了,然后问这个问题,我就什么都没有了。
https://stackoverflow.com/questions/41795040
复制相似问题