火力地堡认证+火力地堡贮存在Unity3d
问题描述:
我不明白如何通过在存储认证的价值... 下面是它试图写入文件时返回的错误,以及代码本身的下方。 有没有人遇到过这样的问题?火力地堡认证+火力地堡贮存在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");
}
});
}
答
火力地堡认证与UnitySDK不上UnityEditor工作(也是独立的)
https://github.com/firebase/quickstart-unity/issues/3
您是否仅在UnityEditor上尝试过? 它可以在iOS或Android上使用。
不过,我也想办法在独立游戏中使用火力地堡认证与Unity3D。
Using Firebase Authentication with Unity on standalone game
如果你已经尝试过在iOS或Android,然后问这个,我什么都没有了。
我在Android上试过了,我有一切工作。谢谢您的帮助!与独立的问题我也很感兴趣,将等待答案:) –
你能用谷歌使用Firebase登录? 我停留在获取(串id_token,字符串的access_token)为Firebase.Auth.GoogleAuthProvider.GetCredential方法。 请告诉我哪里错了? –