title: How to send an HTTP GET request using Firebase and Angular?
body: <p>My app uses IBM Watson Speech-to-Text, which requires an access token. From the command line I can get the access token with curl:</p>
  
  <pre><code>curl -X GET --user my-user-account:password \
  --output token \
  "https://stream.watsonplatform.net/authorization/api/v1/token?url=https://stream.watsonplatform.net/speech-to-text/api"
  </code></pre>
  
  <p>When I make an HTTP request using Angular's <code>$http</code> service I get a CORS error:</p>
  
  <pre><code>var data = {
    user: 'my-user-account:password',
    output: 'token'
  };
  
  $http({
      method: 'GET',
      url: 'https://stream.watsonplatform.net/authorization/api/v1/token?url=https://stream.watsonplatform.net/speech-to-text/api',
      data: data,
  }).then(function successCallback(response) {
    console.log("HTTP GET successful");
  }, function errorCallback(response) {
    console.log("HTTP GET failed");
  });
  </code></pre>
  
  <p>The error message says:</p>
  
  <blockquote>
    <p>No 'Access-Control-Allow-Origin' header is present on the requested
    resource. Origin '<a href="http://127.0.0.1:8080" rel="nofollow noreferrer">http://127.0.0.1:8080</a>' is therefore not allowed
    access. The response had HTTP status code 401.</p>
  </blockquote>
  
  <p>As I understand, it's not possible to do CORS from Angular; CORS has to be done from the server. I know how to do CORS with Node but I'm using Firebase as the server. </p>
  
  <p>Firebase has <a href="https://firebase.google.com/docs/functions/http-events" rel="nofollow noreferrer">documentation</a> about making HTTP requests with CORS. The documentation says to write this:</p>
  
  <pre><code>$scope.getIBMToken = functions.https.onRequest((req, res) =&gt; {
    cors(req, res, () =&gt; {
  
    });
  });
  </code></pre>
  
  <p>First, that doesn't work. The error message is <code>functions is not defined</code>. Apparently <code>functions</code> isn't in the Firebase library? I call Firebase from <code>index.html</code>:</p>
  
  <pre><code>&lt;script src="https://www.gstatic.com/firebasejs/4.3.0/firebase.js"&gt;&lt;/script&gt;
  </code></pre>
  
  <p>My controller injects dependencies for <code>$firebaseArray</code>, <code>$firebaseAuth</code>, and <code>$firebaseStorage</code>. Do I need to inject a dependency for <code>$firebaseHttp</code> or something like that?</p>
  
  <p>Second, how do I specify the method ('GET'), the URL, and the data (my account and password)?</p>