首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >Unity3d中的防火墙身份验证+防火墙存储

问Unity3d中的防火墙身份验证+防火墙存储
EN

Stack Overflow用户
提问于 2017-01-22 19:09:08
回答 1查看 1.3K关注 0票数 1

我不知道如何在存储中传递身份验证的值.下面是试图写入文件时返回的错误,以及代码本身下面的错误。有人遇到过这样的问题吗?

权限规则使用标准

代码语言:javascript
复制
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:服务器已结束上传会话-内部异常堆栈跟踪的结束

代码语言:javascript
复制
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");
            }
        });
    }
EN

回答 1

Stack Overflow用户

回答已采纳

发布于 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或安卓上试过了,然后问这个问题,我就什么都没有了。

票数 3
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/41795040

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档