title: How to fix 'Access token has insufficient scope' error in PHP with Google API?
body: <p>The goal is to upload server files to user's google drive.</p>
  
  <p>To achieve this I am using <a href="https://developers.google.com/identity/sign-in/web/server-side-flow" rel="nofollow noreferrer">Google server-side SignIn</a> to get offline authentication code which I send to my PHP server app where I am using <a href="https://github.com/googleapis/google-api-php-client" rel="nofollow noreferrer">Google API PHP library</a> to authorize my users.</p>
  
  <p>I have made a pretty simple setup on <a href="https://console.developers.google.com" rel="nofollow noreferrer">Google Dev Console</a> Where I've made a project and enabled Google Drive API + added OAuth2 credentials which I use for SignIn and Drive API authentication.</p>
  
  <p>The whole authorization process is working. I can get the actual authorization code from user, authenticate it with client from PHP library and get authentication token.</p>
  
  <p>Now, when I try to actually upload the file to Google Drive i get an error from the library (and the response too):</p>
  
  <pre><code>{
    "error": {
      "errors": [
        {
          "domain": "global",
          "reason": "insufficientPermissions",
          "message": "Insufficient Permission: Request had insufficient authentication scopes."
        }
      ],
      "code": 403,
      "message": "Insufficient Permission: Request had insufficient authentication scopes."
    }
  }
  </code></pre>
  
  <p>What scopes am I missing? Why is this not included in error message? Is this even a "correct" error? I have looked for a solution for past few days and it's starting to drive me crazy, especially since I have already successfully been able to upload file to server using <a href="https://developers.google.com/drive/api/v3/quickstart/php" rel="nofollow noreferrer">this guide</a>. The downside of following this guide is, you force users to go to a generated link, authorize via sign in, then copy and send manually the code to the server via form. Not the acceptable solution for the problem I am trying to solve.</p>
  
  <p>Out of desperation I've went on list of scopes for google api, and just added them all to client object. Didn't help tho.</p>
  
  <p>Does anyone else have same issues as me trying to use this PHP library? All help is appreciated.</p>