[英]Firebase for Unity3d, always test mode authentication Unity Editor
[英]Firebase Authentication + Firebase Storage in 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 = "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");
}
});
}
使用UnitySDK的Firebase身份验证现在无法在UnityEditor上运行。(也是独立的)
https://github.com/firebase/quickstart-unity/issues/3
你是否只在UnityEditor上试过它? 它可能适用于iOS或Android。
但是,我也在寻找在与Unity3D的独立游戏中使用Firebase身份验证的方法。
在独立游戏中使用带有Unity的Firebase身份验证
如果您已经在iOS或Android上尝试过它然后问这个,我什么都没有了。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.