Google Cloud API php authentication fails

I closely followed the docs

https://github.com/googleapis/google-api-php-client/blob/main/docs/oauth-server.md

https://developers.google.com/android-publisher/getting_started?hl=en

  1. Created an service account on Google Cloud Console

  2. generated the key json file and saved as credentials.json

  3. enabled Google Play Android Developer API

  4. invited the service account email in the Google Play Console

  5. granted the permissions

  6. i use this code in php

     putenv('GOOGLE_APPLICATION_CREDENTIALS='.__DIR__.'/credentials.json');
     $client = new GoogleClient();
     $client->useApplicationDefaultCredentials();
     $client->addScope('https://androidpublisher.googleapis.com');
     $service = new Google_Service_AndroidPublisher($client);
    

We get this error message:

"error": {
    "code": 401,
    "message": "Request had invalid authentication credentials. Expected OAuth 2 access token, login cookie or other valid authentication credential. See https://developers.google.com/identity/sign-in/web/devconsole-project.",
    /n"errors": [
      {
        "message": "Invalid Credentials",
        "domain": "global",
        "reason": "authError",
        "location": "Authorization",
        "locationType": "header"
      }
    ],
    "status": "UNAUTHENTICATED"

May or may not be relevant, but the google account on Google Cloud and Google Play Console is the same and part of Google Workspaces but not the organisations account (the same procedure with the organisation account yields the same error message though)