title: Google Drive API Says "Forbidden" When Fetching File
body: <p>For some reason I want to fetch the file from the google drive and process it on the server. From the picker I am getting the FileID and sending it to backend for download and the processing. So on downloading the file using googleapis, I am getting this error</p>
  <p><a href="https://i.stack.imgur.com/lQ37M.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/lQ37M.png" alt="enter image description here" /></a></p>
  <p><strong>Prerequisites</strong></p>
  <ol>
  <li>Drive API is Enabled in the Project</li>
  <li>Access Token has the permission to Drive</li>
  </ol>
  <p><strong>Permissions I have Tried</strong></p>
  <ol>
  <li><a href="https://www.googleapis.com/auth/drive.readonly" rel="nofollow noreferrer">https://www.googleapis.com/auth/drive.readonly</a></li>
  <li><a href="https://www.googleapis.com/auth/drive.file" rel="nofollow noreferrer">https://www.googleapis.com/auth/drive.file</a></li>
  <li><a href="https://www.googleapis.com/auth/drive" rel="nofollow noreferrer">https://www.googleapis.com/auth/drive</a></li>
  </ol>
  <p>The Code I am Using is from the GitHub</p>
  <pre class="lang-js prettyprint-override"><code>const tmpDir = path.resolve(path.join(os.tmpdir(), &quot;user-sheets&quot;));
  const file = path.join(tmpDir, Date.now().toString());
  
  let stream = fs.createWriteStream(file);
  let drive = google.drive({
      version: &quot;v3&quot;,
      auth: &quot;MY ACCESS TOKEN&quot;,
  });
  
  drive.files
      .get(
          {
              fileId: req.body.url,
              alt: &quot;media&quot;,
              oauth_token: &quot;MY ACCESS TOKEN&quot;,
          },
          {
              responseType: &quot;stream&quot;,
          }
      )
      .then((r) =&gt; {
          r.data
              .on(&quot;end&quot;, async () =&gt; {
                  console.log(&quot;ended&quot;);
                  stream.close();
              })
              .on(&quot;error&quot;, function (err) {
                  console.log(&quot;Error during download&quot;, err);
                  res.json({
                      success: false,
                      message: &quot;Something went wrong&quot;,
                      error: err,
                  });
              })
              .pipe(stream);
      })
      .catch((e) =&gt; {
          console.error(e.response);
      });
  </code></pre>