Note that there are some explanatory texts on larger screens.

plurals
  1. POfirebase gives me permission denied when using php
    primarykey
    data
    text
    <p>I'm trying to write to a firebase with php using REST and i keep getting permission denied</p> <p>I'm using the test file like this:</p> <pre><code>$url = 'https://my.firebase.url/'; $atoken = '?auth=MY FIREBASE SECRET'; $fb = new fireBase($url); $todos = array( 'name' =&gt; 'Pick the milk', 'priority' =&gt; 1 ); $todoPath = '/test/test'; printf("Database: %s\n", $url); printf("Sending data to %s\n", $todoPath); $response = $fb-&gt;set($todoPath, $todos.$atoken); printf("Result: %s\n", $response); printf("Reading data from %s\n", $todoPath); $response = $fb-&gt;get($todoPath); printf("Result: %s\n", $response); </code></pre> <p>I have rules set up that only a specific authorized user "me" the admin can write to the the firebase but anyone can read from in. This was fine when the code was in Javascript because I would log in and be authorized. But now it's in php and I thought the "SECRET" would make that work or at lease I was lead to believe that by the firebase DOCS.</p> <p>So what am I doing wrong?</p> <p>Thank you!</p> <p>UPDATE:</p> <p>So I changed the:</p> <pre><code>$atoken = '?auth=MY FIREBASE SECRET'; </code></pre> <p>to be</p> <pre><code>$atoken = '.json?auth=MY FIREBASE SECRET'; </code></pre> <p>and I put it here:</p> <pre><code>printf("Sending data to %s\n", $todoPath.$atoken); $response = $fb-&gt;set($todoPath.$atoken, $todos); printf("Result: %s\n", $response); printf("Reading data from %s\n", $todoPath.$atoken); $response = $fb-&gt;get($todoPath.$atoken); printf("Result: %s\n", $response); </code></pre> <p>Now I get this Error:</p> <pre><code>04Database: https://MYDATABASE/ Sending data to /test/test.json?auth=MY FIREBASE SECRET Result: { "error" : "invalid_token: Could not parse auth token." } Reading data from /test/test.json?auth=MY FIREBASE SECRET Result: { "error" : "invalid_token: Could not parse auth token." } </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload