title: How to put a trigger to another Firebase Database from Firebase Functions?
body: <p>I'm trying to trigger my database function when something is wrote to a database from an associate.
  I know that I need a Service Account created in the other database and the .json file that firebase gives to do the connection properly. Right now I'm giving all the permissions for getting sure than my errors don't come from this.<br>
  With what I found on the documentation and with other information on internet, this is how I login to the other database:</p>
  
  <pre><code>var adminAbi = require("firebase-admin");
  var functionsAbi = require('firebase-functions');
  
  const serviceAccount = require(`./serviceacountfile.json`);
  adminAbi.initializeApp({
    credential: adminAbi.credential.cert(serviceAccount),
    databaseURL: 'https://DATABASEURL.firebaseio.com/',
  },'test' );
  </code></pre>
  
  <p>And this is my trigger:</p>
  
  <pre><code>exports.copyDatabasess = functionsAbi.database.instance('test').ref('/messages/{user_id}/{now}').onWrite(event =&gt;{
    if (!event.data.exists()) {
      return;
      }
      console.log('copydatabase', event.params.body);
    // Grab the current value of what was written to the Realtime Database.
    const original = event.data.val(); 
  });
  </code></pre>
  
  <p>With this code I'm getting right now this error when I deploy:</p>
  
  <blockquote>
    <p>!  functions[copyDatabasess]: Deployment error. Failed to configure
    Firebase Realtime Database trigger: unknown error, HTTP code 401</p>
  </blockquote>
  
  <p>I really can't find useful informations about this error and how to solve it. If someone knows something about this would be much appreciated.<br>
  Thanks in advice.</p>