title: Firebase Authentication from Google App Script?
body: <p>I'm trying to add firebase authentication to my google doc add on. My goal is to have a sidebar that displays data from my database after authentication. I get the most confused by other answers because I'm unsure about what goes in the html file verse what goes in the google app script file. I know I'm supposed to create a token but after I copy and paste that code from the tutorial I get lost.</p>
  
  <p>Groups/Answers that were partly helpful:</p>
  
  <p><a href="https://groups.google.com/forum/#!topic/firebase-talk/-RKpHaMPTYQ" rel="nofollow noreferrer">https://groups.google.com/forum/#!topic/firebase-talk/-RKpHaMPTYQ</a></p>
  
  <p><a href="https://stackoverflow.com/questions/38949432/google-authentication-with-google-spread-sheet-via-app-script">Google Authentication with Google Spread Sheet via App Script</a></p>
  
  <p><a href="https://sites.google.com/site/scriptsexamples/new-connectors-to-google-services/firebase/tutorials/using-secured-client-authentication-for-real-time-read-and-write-calls" rel="nofollow noreferrer">https://sites.google.com/site/scriptsexamples/new-connectors-to-google-services/firebase/tutorials/using-secured-client-authentication-for-real-time-read-and-write-calls</a></p>
  
  <p>app.html</p>
  
  <pre><code>&lt;html lang="en"&gt;
  &lt;head&gt;
    &lt;script src="https://www.gstatic.com/firebasejs/3.7.3/firebase.js"&gt;&lt;/script&gt;
    &lt;script&gt;
    var config = {
      apiKey: "",
      authDomain: "",
      databaseURL: "",
      storageBucket: "",
      messagingSenderId: ""
    };
    firebase.initializeApp(config);
    &lt;/script&gt;
  
  &lt;/head&gt;
  
  &lt;body&gt;
  
  &lt;div id="databaseDiv"&gt;&lt;/div&gt;
  
  &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>
  
  <p>Code.gs</p>
  
  <pre><code>/**
   * Creates a menu entry in the Google Docs UI when the document is opened.
   * This method is only used by the regular add-on, and is never called by
   * the mobile add-on version.
   *
   * @param {object} e The event parameter for a simple onOpen trigger. To
   *     determine which authorization mode (ScriptApp.AuthMode) the trigger is
   *     running in, inspect e.authMode.
   */
  function onOpen(e) {
    DocumentApp.getUi().createAddonMenu()
        .addItem('Start', 'showSidebar')
        .addToUi();
  }
  
  function onInstall(e) {
    onOpen(e);
  }
  
  function showSidebar() {
    var ui = HtmlService.createHtmlOutputFromFile('app')
        .setTitle('Sow Google Docs');
    DocumentApp.getUi().showSidebar(ui);
  }
  
  function makeToken(){ 
  
    var firebaseUrl = "https://example.firebaseio.com/"; 
    var secret = "EXAMPLEKEYYEKELPMAXE"; 
    var base = FirebaseApp.getDatabaseByUrl(firebaseUrl, secret); 
    var token = base.createAuthToken(Session.getActiveUser().getEmail()); 
    return token; 
  
  }
  </code></pre>
  
  <p>What am I missing?</p>