title: Google Sheet API : "message": "The request is missing a valid API key."
body: <p>I'm trying to make an extencion that will take some data from page and send it to google sheet. 
  My manifest:</p>
  
  <pre><code>"oauth2": {
          "client_id": "client_id",
          "scopes": ["https://www.googleapis.com/auth/spreadsheets"] 
      },
      "permissions": [
          "activeTab",
          "tabs", 
          "https://*.*/*",
          "storage",
          "declarativeContent",
          "identity",
          "https://ssl.gstatic.com/",
          "https://www.googleapis.com/*",
          "https://accounts.google.com/",
          "https://sheets.googleapis.com/",
          "https://www.googleapis.com/auth/spreadsheets/"
      ],
      "key": {key}
  </code></pre>
  
  <p>background page:</p>
  
  <pre><code>var tokenS;
  chrome.runtime.onInstalled.addListener(function() {
    chrome.storage.sync.set({number: value}, function(data) {
    });
      chrome.identity.getAuthToken({
          interactive: false
      }, function(token) { 
          tokenS = token
          console.log(token)
      });
  });
  function writeData(request, sender){
      myspreadsheetId = "myspreadsheetId " 
      var params = {
          "range":"Sheet1!A1:A",
          "majorDimension": "ROWS",
          "values": [
              [request.name]
          ],
      }
      var xhr = new XMLHttpRequest();
      xhr.open('PUT', 'https://sheets.googleapis.com/v4/spreadsheets/' + myspreadsheetId + '/values/Sheet1!A1:A1?valueInputOption=USER_ENTERED');
      console.log(tokenS)
      xhr.setRequestHeader('Authorization', 'Bearer '+tokenS);
      xhr.send(JSON.stringify(params));
  };
  chrome.runtime.onMessage.addListener(writeData)
  </code></pre>
  
  <p>I receive next error:</p>
  
  <pre><code>{
    "error": {
      "code": 403,
      "message": "The request is missing a valid API key.",
      "status": "PERMISSION_DENIED"
    }
  }
  </code></pre>
  
  <p>at google cloud platform I see a 100% error ratio (<a href="http://prntscr.com/jvfl0c" rel="nofollow noreferrer">http://prntscr.com/jvfl0c</a>). And I do not understand what I'm doing wrong. Pleasse help.</p>