title: Update a Google Sheet using REST calls with Google Sheets API
body: <p>I'm trying to write some data to a google spreadsheet using REST API calls from Postman or Curl. By following the official documentation, some tutorials and blogs, I have done the following.</p>
  <ol>
  <li>Create a Google Console Project.</li>
  <li>Enable Google Sheet API.</li>
  <li>Create a new service and download keys JSON file (with sheets API access and editor role).</li>
  <li>Activate service account using Google cloud SDK (<code>CLI command: gcloud auth activate-service-account --key-file keys.json</code>)</li>
  <li>Obtain the access token (<code>CLI command: gcloud auth print-access-token</code>)</li>
  </ol>
  <p>The Google spreadsheet I want to write data is private and only the REST client and myself should able to write data. Also <strong>creating OAuth credentials and using them to authenticate REST application is not possible</strong> as this doesn't involve any user. Also, I <strong>can't share the spreadsheet with the service account generated mail (from the UI)</strong>, as the sharing outside option is disabled by the organization. <strong>Deploying the sheet to public is also not possible</strong>.</p>
  <p>All the resources I found online asks to add the service account mail to the sheet from the UI. Is there any other method to make this happen as that is not possible in my case?</p>
  <p><em><strong>Note</strong></em></p>
  <p>I'm Getting the following error (since I haven't shared my sheet with the service account mail)</p>
  <pre><code>{
      &quot;error&quot;: {
          &quot;code&quot;: 403,
          &quot;message&quot;: &quot;Request had insufficient authentication scopes.&quot;,
          &quot;status&quot;: &quot;PERMISSION_DENIED&quot;,
          &quot;details&quot;: [
              {
                  &quot;@type&quot;: &quot;type.googleapis.com/google.rpc.ErrorInfo&quot;,
                  &quot;reason&quot;: &quot;ACCESS_TOKEN_SCOPE_INSUFFICIENT&quot;,
                  &quot;domain&quot;: &quot;googleapis.com&quot;,
                  &quot;metadata&quot;: {
                      &quot;service&quot;: &quot;sheets.googleapis.com&quot;,
                      &quot;method&quot;: &quot;google.apps.sheets.v4.SpreadsheetsService.GetValues&quot;
                  }
              }
          ]
      }
  }
  </code></pre>