title: Using the Google Auth Library to authenticate Google Drive
body: <p>I am using the node Google Auth Library to get an authorized client. I know this step is successful from the line <code>console.log('Project ID', await auth.getProjectId())</code> which prints the correct result. I am getting an error when I try to use this authorized client to authenticate the Google Drive api:</p>
  
  <p><code>Error: invalid_scope: Invalid OAuth scope or ID token audience provided.</code></p>
  
  <p>Code:</p>
  
  <pre><code>import { google } from 'googleapis'
  const { GoogleAuth } = require('google-auth-library')
  import { config } from 'dotenv'
  import { resolve } from 'path'
  
  /**
   * GCLOUD_PROJECT and GOOGLE_APPLICATION_CREDENTIALS are set
   * in the top-level .env file, GoogleAuth requires these to be set
   */
  config({ path: resolve(__dirname, '../.env')})
  
  const main = async () =&gt; {
      const csv = ''
      const auth = await getAuthClient()
      await uploadToGoogleDrive({ csv, auth })
  }
  
  const getAuthClient = async () =&gt; {
      const scopes = ['https://www.googleapis.com/auth.drive']
      const auth = new GoogleAuth({ scopes })
      console.log('Project ID', await auth.getProjectId())
      return await auth.getClient()
  }
  
  const uploadToGoogleDrive = async ({ csv, auth }) =&gt; {
      const drive = google.drive({
          version: 'v3',
          auth,
      })
  
      await drive.files.create({
          requestBody: {
              name: 'test.csv',
              mimeType: 'text/plain',
              parents: ['** Parent Folder Name **']
          },
          media: {
              mimeType: 'text/csv',
              body: csv
          }
      })
  }
  
  main().catch(console.error)
  </code></pre>