php - 火力基地: "Could not parse auth token."

标签 php firebase firebase-authentication

你好,我正在使用带有 php 的 firebase 并使用这个 library .

我收到此错误“无法解析身份验证 token 。”

我的授权 token 是正确的,因为我也使用了与 node.js 相同的 token 。

我的代码是这样的

       require "vendor/autoload.php";
       const DEFAULT_URL = 'https://xxxxxxxxx.firebaseio.com';
       const DEFAULT_TOKEN = 'xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx';

       $firebase = new \Firebase\FirebaseLib(DEFAULT_URL, DEFAULT_TOKEN );  

        $data = [
        "Website_Name"=> $Website_Name,
        "Username" =>  $Username,
       "Password"=> $Password,
       "website_link"=> $website_link,
       "id"=> $id,
       ];



        $path = "per_users";
        $res = $firebase->push('/per_users', $data);
        // per_users is the name of the table
        var_dump($res); 

你能告诉我我到底做错了什么吗? 谢谢。

最佳答案

我发现以下解决方案有效,如果有人仍想使用主题启动器的 library :

  1. 转到 Firebase Console并选择您的项目。
  2. 转到项目设置(按左上角概述旁边的齿轮图标)
  3. 转到“服务帐户”标签
  4. 选择 Database Secrets,显示并复制库的 const DEFAULT_TOKEN
  5. 的数据库 key

enter image description here

关于php - 火力基地: "Could not parse auth token.",我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39550635/

相关文章:

swift - Firebase 无法导入桥接头

swift - 如何检查电子邮件地址是否已在使用 Firebase

php - 是否应该在PHP中使用$ this-> var声明和访问方法属性?

php - 使用 Mikehaertl 的 WkHtmlToPdf 创建横向 PDF

ios - Value of type 'QuerySnapshot' has no member 会出现 'data'错误

javascript - 为什么刷新时不再对 Firebase 用户进行身份验证?

ios - 在 Firebase 身份验证 Xamarin 中访问 UID 时出错

php - laravel 5.2 在 app.php 中设置默认语言环境不起作用

php - 在 Laravel 中的 MySQL 中插入 JSON 对象

node.js - 使用 Firebase、Material Design Components (MDC) 和 Node.js