title: Google Sheets API throwing 401 error while append rows to spreadsheet without login
body: <p><strong>Objective:</strong> Submit a form and store data to google spreadsheet</p>
  
  <p>documentation: <a href="https://developers.google.com/sheets/api/quickstart/js" rel="nofollow noreferrer">link</a></p>
  
  <p><strong>What I've done so far:</strong></p>
  
  <pre><code>var CLIENT_ID = 'my_client_id.apps.googleusercontent.com';
  var API_KEY = 'MY_API_KEY';
  var DISCOVERY_DOCS = ["https://sheets.googleapis.com/$discovery/rest?version=v4"];
  var SCOPES = "https://www.googleapis.com/auth/spreadsheets";
  
  var authorizeButton = document.getElementById('authorize_button');
    var signoutButton = document.getElementById('signout_button');
   function handleClientLoad() {
      gapi.load('client:auth2', initClient);
    }
  function initClient() {
      gapi.client.init({
        apiKey: API_KEY,
        clientId: CLIENT_ID,
        discoveryDocs: DISCOVERY_DOCS,
        scope: SCOPES
      })
  function updateSigninStatus(isSignedIn) {
      if (isSignedIn) {
        //authorizeButton.style.display = 'none';
        //signoutButton.style.display = 'block';
        //listMajors();
      } else {
        //authorizeButton.style.display = 'block';
        //signoutButton.style.display = 'none';
      }
    }
  function appendPre(message) {
      var pre = document.getElementById('content');
      var textContent = document.createTextNode(message + '\n');
      pre.appendChild(textContent);
    }
  function update_docs(data) {
      var params = {
        spreadsheetId: '1YXMlr_-I45AWM2b9QnLkuLQoI6dq6wEuVOcttOMv9hU',
        range: 'A:I',  // TODO: Update placeholder value.
        valueInputOption: 'RAW',
        insertDataOption: 'INSERT_ROWS',
      };
  
    var valueRangeBody = {
  
      "range": 'A:I', // 9 cols
      "majorDimension": 'ROWS',
      "values": [
        [
          data[0].value,//nom,
          data[1].value,//prenom,
          data[2].value,//email,
          data[3].value,//user_phone,
          data[4].value,//company_name,
          data[5].value,//user_type,
          data[6].value,//account_name,
          data[7].value,//password,
          data[8].value,//comptes_sources,
        ]
      ]
  
    };
  
    var request = gapi.client.sheets.spreadsheets.values.append(params, valueRangeBody);
    request.then(function(response) {
      console.log(response.result);
    }, function(reason) {
      console.error('error: ' + reason.result.error.message);
    });
  }
  </code></pre>
  
  <p>I can successfully append rows to the spreadsheet if I'm logged in to my google account.</p>
  
  <p><strong>Question:</strong> Can I append row without logging in(if yes please provide some docs/code)?
  Because if I submit the form from a private window it throws 401 error.</p>
  
  <p><strong>error message:</strong> <code>error: Request is missing required authentication credential. Expected OAuth 2 access token, login cookie or other valid authentication credential.</code> </p>