如何修复“ Firebase.Storage.StorageException:无权执行用户所需的操作”,尽管登录和存储规则已成功完成?

时间:2019-05-14 20:20:06

标签: ios firebase unity3d firebase-authentication firebase-storage

Unity 2018.3.11f1

XCode 10.2.1

Firebase 6.0.0(身份验证和存储)

在尝试运行我的AR应用程序时,遇到一个错误,尽管通过Firebase与其他用户成功登录,但我没有获得下载期望文件的授权。

我尝试使用auth.Dispose()杀死我现有的Authentication实例,并尝试使用auth.SignOut()退出现有用户,然后再转到下一个场景,没有任何变化。否则,我不确定如何解决此问题。与我的其他操作系统中的代码相比,此代码没有什么区别。此外,我的Firebase存储的规则在所有用户中都是通用的,因此这不是问题。

我的认证码,供对它的详细信息感兴趣的人使用

    void Start ()
    {

        //Establish instance of Firebase Authentication
        auth = FirebaseAuth.DefaultInstance;
        UserNameInput.text = "";
        PasswordInput.text = "";
        Debug.Log(Application.persistentDataPath);

        //Run the Login method when the LoginButton is pressed, taking the inputs
        LoginButton.onClick.AddListener(() => InternetChecker(UserNameInput.text, PasswordInput.text));

    }

(此InternetChecker方法最终会将电子邮件/密码输入吐入Login方法)


    public void Login(string email, string password)
    {
        //Runs Firebase's Authentication Async-style, storing the result in a User variable and displaying this info to the Console
        auth.SignInWithEmailAndPasswordAsync(email, password).ContinueWith(task =>
        {
            if (task.IsCanceled)
            {
                Debug.Log("SignInWithEmailAndPasswordAsync canceled.");
                return;
            }
            if (task.IsFaulted)
            {
                Debug.Log("SignInWithEmailAndPasswordAsync error: " + task.Exception);
                if (task.Exception.InnerExceptions.Count > 0)
                {
                    UpdateErrorMessage(task.Exception.InnerExceptions[0].Message);
                }
                return;
            }
            FirebaseUser user = task.Result;
            Debug.LogFormat("User signed in successfully: ({0}) ({1})", user.DisplayName, user.UserId);
            userrr = user;

            //Reference to ALL of Storage
            Firebase.Storage.FirebaseStorage storage = Firebase.Storage.FirebaseStorage.DefaultInstance;

(...等,以便执行我的存储下载...)

在Windows 10 / MacOS / Android上,我的应用正常运行。我使用电子邮件/密码以[USER 1]身份登录,登录成功并显示UserID,我的文件(资产捆绑包和AR插件数据库)被下载到应用程序中并被使用/实例化,并且应用程序从我的登录场景到AR场景。然后,我可以返回登录场景(通过简单地卸载捆绑包并加载登录的按钮),此后,我可以以[USER 2]身份登录。新的登录会发生,文件会被另一组替换,然后会再次加载AR场景。

但是,在iOS上(iPad Mini 4和新的iPad Pro Gen.3),这太糟了。我打开该应用程序,以[USER 1]身份登录,一切顺利。然后,返回并以[USER 2]身份登录,我再次成功登录,但是此后所有下载请求均失败,并显示错误:

“ Firebase.Storage.StorageException:用户无权执行所需的操作。”

解释?我不确定如何才能“成功登录”并显示正确的Firebase用户ID,但随后未经授权就无法获得该新登录所允许的一切,更不用说仅在iOS上了。另外,哪个用户是User 1哪个用户是2,3,4,等等。在我完全杀死该应用程序之前,只有第一个用户才能工作,此后,只有另一个第一个尝试过的用户才能再次工作。

0 个答案:

没有答案