1

ストレージ内の認証の値を渡す方法を理解できません... 以下は、ファイルを書き込もうとしたときに返されるエラーです。 誰もそのような問題に直面していますか?タイプ 'System.AggregateException' の例外がスローされた:Unity3dのFirebase認証+ Firebaseストレージ

許可規則は、標準

service firebase.storage { 
    match /b/project.appspot.com/o { 
    match /{allPaths=**} { 
     allow read, write: if request.auth != null; 
    } 
    } 
} 

System.AggregateExceptionを使用しています。 ----------------- Firebase.Storage.StorageException:ユーザーはこのオブジェクトにアクセスするためのアクセス許可を持っていません。 ---> System.IO.IOException:UnitySDKと サーバは---内部例外 スタックトレースの終わりをアップロードセッションを終了しました---

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"); 
      } 
     }); 
    } 

答えて

3

Firebase認証がUnityEditor上では動作しません。今(スタンドアロン)
https://github.com/firebase/quickstart-unity/issues/3
UnityEditorで試したことがありますか? iOSやAndroidで動作する可能性があります。

しかし、Unity3DでスタンドアロンゲームでFirebase認証を使用する方法も探しています。
Using Firebase Authentication with Unity on standalone game

すでにiOS版やAndroid上でそれを試してみましたが、その後、これを聞いている場合は、私はもう何もありません。

+2

私はAndroidで試してみました。助けてくれてありがとう!スタンドアロンの問題も私は非常に興味がある、答えを待っているでしょう:) –

+0

あなたはfirebaseを使用してGoogleとログインすることはできますか? Firebase.Auth.GoogleAuthProvider.GetCredentialメソッドの(文字列id_token、文字列access_token)を取得できませんでした。 私はどこが間違っているのかアドバイスしてください。 –