title: Connecting Rails Application to Firebase Cloud Firestore
body: <p>Would Like to read Data from the Firebase Cloud Firestore. I have already created a project, and added my Rails (6.0.3) application to the fire store db via settings -&gt; add web app. This provided me with script tags containing the firevbase SDK to add to my web application under the body tag, I did all of this.
  I am trying to follow the instructions @ <a href="https://firebase.google.com/docs/firestore/quickstart?authuser=0#ruby" rel="nofollow noreferrer">https://firebase.google.com/docs/firestore/quickstart?authuser=0#ruby</a>. The very first instruction reads:
  '''
  export GOOGLE_APPLICATION_CREDENTIALS=&quot;path/to/your/keyfile.json&quot;
  '''
  I have already downloaded this JSON file by creating a key from the service account associated with my firebase project, this key was downloaded and placed within my project tree. However I do not know where to put Export google creds within my Rails environment? Previously I tried to insert it into environment/development.rb but the export key word is not a part of Ruby syntax.</p>
  <p>I have already installed the cloud-firestore-gem and I have been working through this post trying to piece everything together <a href="https://stackoverflow.com/questions/57101015/how-to-connect-to-a-firestore-database-with-ruby">How to connect to a Firestore database with Ruby</a>. When I run this within the rails console:</p>
  <pre><code>cred = Google::Cloud::Firestore::Credentials.new(&quot;path/to/myJsonSerivcesKey.Json&quot;) 
  </code></pre>
  <p>I receive this trace back :</p>
  <pre><code>Signet::AuthorizationError (Authorization failed.  Server message:)
  {&quot;error&quot;:&quot;invalid_scope&quot;,&quot;error_description&quot;:&quot;Invalid OAuth scope or ID token audience provided.&quot;}
  </code></pre>
  <p>I think this error has to do with me not doing something correct when using the API key from the service account but I am not really sure. Any advice on how to correct the Invalid OAuth Scope and where to put the export GOOGLE_APPLICATIONS+CREDENTIALS would be great. Also I am not sure why Firebase SDK needs to be pasted into the body tags of the application, could someone explain what this does for the app?</p>