title: Problem in adding data through admin.firestore()
body: <p>My current firestore rules in my project:</p>
  
  <p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
  <div class="snippet-code">
  <pre class="snippet-code-js lang-js prettyprint-override"><code>service cloud.firestore {
    match /databases/{database}/documents {
      match /auth_url/{auth_doc} {
        allow read, write: if request.auth.uid != null;
      }
      match /nonauth_url/{nonauth_doc}{
        allow read, write: if false ;
      }
    }
  }</code></pre>
  </div>
  </div>
  </p>
  
  <hr>
  
  <p><code>auth_url</code> collection is for authorized users and running perfectly (addition, creation, deletion etc of documents) and <code>nonauth_url</code> collection is for non authenticated users, by jquery post request through client.js I'm adding data by using <code>admin.firestore()</code> in my server (index.js) but in my cloud firestore section there is no data present there. Are my firestore rules wrong somewhere ?</p>
  
  <hr>
  
  <p>client.js</p>
  
  <p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
  <div class="snippet-code">
  <pre class="snippet-code-js lang-js prettyprint-override"><code>function renderList(user){
  
      let db = firebase.firestore() ;
      
      stopListner = db.collection('auth_url').doc(user.email).onSnapshot( (doc) =&gt; {
          var objOfObj = doc.data() ;
          let newarrOfObjects = [] ;
          
          for( key in objOfObj){
              newarrOfObjects.push(Object.assign(objOfObj[key], {name: key})) ;
          }
          $('.container.urlsList').html('') ;
          newarrOfObjects.forEach( (obj, pos) =&gt; {
              if( obj.code != ''){
  
                  $('.container.urlsList').append(`
                  &lt;div id="accordion${pos+1}" class="myUrlSlot"&gt;
                  &lt;div class="card"&gt;
                  &lt;div class="card-header d-flex flex-row align-items-center p-2"&gt;
                  
                  &lt;button class="btn btn-outline-dark rounded-circle" data-toggle="collapse" data-target="#${pos+1}"&gt;&lt;i class="fa fa-plus"&gt;&lt;/i&gt;&lt;/button&gt;
                  
                  &lt;div class="w-100 code font-weight-bold"&gt;
                  ${obj.code}
                  &lt;/div&gt;
                  
                  &lt;button data-edit-id="${pos+1}"class="btn btn-outline-primary edit rounded-circle"&gt;&lt;i class="fa fa-pencil"&gt;&lt;/i&gt;&lt;/button&gt;
                  
                  
                  &lt;button data-del-id="${pos+1}" class="btn btn-outline-danger del rounded-circle"&gt;&lt;i class="fa fa-trash"&gt;&lt;/i&gt;&lt;/button&gt;
                  
                  &lt;/div&gt;
                  &lt;div id="${pos+1}" class="collapse info"&gt;
                  &lt;dl class='m-3'&gt;
                  &lt;dt&gt;Shortened URL&lt;/dt&gt;
                  &lt;dd&gt;${window.location.origin+ '/' + obj.code}&lt;/dd&gt;
                  &lt;dt&gt;Redirection URL&lt;/dt&gt;
                  &lt;dd class="redirectUrl"&gt;${obj.redirectUrl}&lt;/dd&gt;
                  &lt;/dl&gt;
                  &lt;/div&gt;
                  &lt;/div&gt;
                  &lt;/div&gt;
                  `) ;
              }
          }) ;
  
          if( $('div.urlsList').children().length == 0){
              $('#emptyMsg').show() ;
           }
           else{
              $('#emptyMsg').hide() ;
           }
  
          
          // changing plus to minus vice-versa
          
          $('.collapse').on('show.bs.collapse', function(){
              $(this).parent().find('.fa-plus').removeClass('fa-plus').addClass('fa-minus') ;
          }).on('hidden.bs.collapse', function(){
              $(this).parent().find('.fa-minus').removeClass('fa-minus').addClass('fa-plus') ;
          }) ;
          
          
          // edit icon
          
          $('.edit').click(function(){
              let target_id = $(this).data('edit-id') ;
              bootbox.dialog({
                  title: 'Change Redirection URL',
                  centerVertical: true,
                  closeButton: false,
                  message: `
                  &lt;form id="changeUrlForm"&gt;
                  &lt;label for="inputUrl"&gt;Enter the New Url&lt;/label&gt;
                  &lt;input type="url" class="form-control text-center" id="inputUrl" name="iurl" placeholder="Enter URL Here"&gt;
                  &lt;/form&gt;
                  `,
                  buttons: {
                      cancel: {
                          label: 'Cancel',
                          className: 'btn-danger'
                      },
                      ok: {
                          label: 'Ok',
                          className: 'btn-primary',
                          callback: function(){
                              $('#changeUrlForm').validate({
                                  rules: {
                                      iurl: {
                                          required: true,
                                          url: true
                                      }
                                  },
                                  messages: {
                                      iurl: {
                                          url: 'Please enter a valid url with "http://" or "https://" first !!'
                                      }
                                  }
                              }) ;
                              if( $('#changeUrlForm').valid()){
                                  let newurl = $('#inputUrl').val() ;
  
                                  var objToBeUpdated = `url${target_id}` ;
  
                                  var updateObj = {} ;
  
                                  updateObj[`${objToBeUpdated}.redirectUrl`] = newurl ;
  
                                  db.collection('auth_url').doc(user.email).update(updateObj).then( () =&gt; {
                                      successAlert(`URL${target_id}'s redirection url updated successfully !!`) ;
                                  }).catch( err =&gt; {
                                      errorAlert(err.code, err.message) ;
                                  }) ;
  
                              }
                              else{
                                  $('label.error').addClass('text-danger');
                                  return false ;
                              }
                          }
                      }
                  }
              }) ;
          }) ;
          
          // del icon
          
          $('.del').click(function(){
              let target_id = $(this).data('del-id') ;
              bootbox.confirm({
                  message: 'Are you sure you want to delete this saved URL ?',
                  centerVertical: true,
                  closeButton: false,
                  buttons: {
                      confirm: {
                          label: 'Yes',
                          className: 'btn-success'
                      },
                      cancel: {
                          label: 'No',
                          className: 'btn-danger'
                      }
                  },
                  callback: function(result){
                      if(result){
                          var updateObj = {
                              [`url${target_id}`]: {
                                  code: '',
                                  redirectUrl: ''
                              }
                          } ;
  
                          db.collection('auth_url').doc(user.email).update(updateObj).then(() =&gt; {
                              successAlert(`URL${target_id} deleted successfully !!`) ;
                          }).catch( err =&gt; {
                              errorAlert(err.code, err.message) ;
                          });
                      }
                  }
              }) ;
          }) ;
      }, (err) =&gt; {
          errorAlert(err.code, err.message) ;
      }) ;
  }
  
  
  
  
  
  $(function(){
      // on authorization endering is working perfectly fine
    firebase.auth().onAuthStateChanged( user =&gt; {
        if( user ){
           if( firebase.auth().currentUser.emailVerified == false ){
              bootbox.dialog(verifyDialogSettings);
           }
           
           if( firebase.auth().currentUser.providerData[0].providerId === 'google.com'){
              $('.changePass, .beforechangePass').hide() ;
           }
           refreshMainPage( user ) ;
           // refreshUrls(user.email) ;
           console.log('signed in state') ;
           $('.login, #newurl, .mainTopic, .middle').hide() ;
           $('.signOutButton, .settings, .welcomemsg, .image, .description, .urlsList').show() ;
           
           // refresh the list
           
           renderList(user) ;
        }
        else{
           console.log('signed out state') ;
           $('.signOutButton, .settings, .welcomemsg, .image, .description, .urlsList, #emptyMsg').hide() ;
           $('.login, #newurl, .mainTopic, .middle').show() ;
        }
     });
     
     
     
  $('.sendUrl').on('click', function(e){
        
        e.preventDefault() ;
        $('#nonauthForm').validate({
           rules: {
              url_nauth: {
                 required: true,
                 url: true
              }
           }
        }) ;
  
        if( $('#nonauthForm').valid()){
           $.post('/nonauth_url',{
                 URL: $('#url').val()
              },function(code, status){
                 if(status === 'success'){
                    $('#newurl').html(`
                    ${window.location.origin+ '/'+ code}
                    `)
                 }
           }) ;
        }
        else{
           $('label.error').addClass('text-danger d-block mt-2');
        }  
  }) ;
  
  
  
  
  }) ;</code></pre>
  </div>
  </div>
  </p>
  
  <hr>
  
  <p>index.js (server)</p>
  
  <p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
  <div class="snippet-code">
  <pre class="snippet-code-js lang-js prettyprint-override"><code>const functions = require('firebase-functions');
  const admin = require('firebase-admin') ;
  const express = require('express') ;
  const urlId = require('shortid') ;
  
  const sp = require('synchronized-promise') ;
  
  const string = require('randomstring') ;
  
  const serviceAccount = require('./url-shortner-xxxx.json') ;
  
  const app = express() ;
  
  admin.initializeApp({
     credential: admin.credential.cert(serviceAccount)
  });
  
  let db = admin.firestore() ;
  let Data = db.collection('nonauth_url') ;
  
  app.post('/nonauth_url', (req, res) =&gt; {
     
     let codeGenerated = 'n' + urlId.generate() ; // n for non-authenticated users
     
     let docname = 'doc-' + string.generate(4) ;
     
     let schema = {
        code: codeGenerated,
        url: req.body.URL,
        expiredAt: Date.now()+600000  // in milisceonds for 10min
     }
     
     let docRef = Data.doc(docname).set(schema) ;
     res.send(schema.code) ;
  }) ;
  
  exports.routeFunc = functions.https.onRequest(app) ;</code></pre>
  </div>
  </div>
  </p>
  
  <p><code>res.send(schema.code)</code> is sending back the code but not creating any docs under <code>nonauth_url</code> collection </p>