title: Request had invalid authentication credentials. Expected OAuth 2 access token error in AutoML API
body: <p>I've followed the Google Cloud AutoML API quickstart of requesting api by using</p>
  
  <pre><code>curl -X POST \
    -H "Authorization: Bearer $(gcloud auth application-default print-access-token)" \
    -H "Content-Type: application/json" \
    https://automl.googleapis.com/v1beta1/projects/kintsugi-415310213303/locations/us-central1/models/TCN1592956918625708154:predict \
    -d '{
          "payload" : {
            "textSnippet": {
                 "content": "YOUR TEXT HERE",
                  "mime_type": "text/plain"
             },
          }
        }'
  </code></pre>
  
  <p>and following <a href="https://cloud.google.com/natural-language/automl/docs/reference/rest/" rel="nofollow noreferrer">link</a>, but I got this error</p>
  
  <pre><code>{
    "error": {
      "code": 401,
      "message": "Request had invalid authentication credentials. Expected OAuth 2 access token, login cookie or other valid authentication credential. Se
  e https://developers.google.com/identity/sign-in/web/devconsole-project.",
      "status": "UNAUTHENTICATED"
    }
  }
  </code></pre>
  
  <p>I referred to <a href="https://stackoverflow.com/questions/48720306/request-had-invalid-authentication-credentials-expected-oauth-2-access-token-er/55823385#55823385">Request had invalid authentication credentials. Expected OAuth 2 access token error in cloud speech api</a>, and tried creating another access token with application-default login and got the below error:</p>
  
  <pre><code>{
    "error": {
      "code": 403,
      "message": "Your application has authenticated using end user credentials from the Google Cloud SDK or Google Cloud Shell which are not supported by
   the automl.googleapis.com. We recommend that most server applications use service accounts instead. For more information about service accounts and how
   to use them in your application, see https://cloud.google.com/docs/authentication/.",
      "status": "PERMISSION_DENIED"
    }
  }
  </code></pre>
  
  <p>I've also enabled permissions similar to this: <a href="https://github.com/googleapis/google-cloud-php/issues/1722" rel="nofollow noreferrer">https://github.com/googleapis/google-cloud-php/issues/1722</a> (AutoML Admin, AutoML Service Agent, AutoML Editor)</p>
  
  <p>I'm the owner/admin of the project. It seems like the tokens are expiring and I may need to implement this server-side. </p>
  
  <p>What should I do now? </p>
  
  <p>Thanks in advance!</p>