Google Sheets API suddenly returns 403 "The caller does not have permission" after working for a month - PHP

This is my first post here, please excuse me if I’m missing something.

I’m using PHP with google/apiclient v2.14.0 to create new spreadsheets via the Google Sheets API using:
POST https://sheets.googleapis.com/v4/spreadsheets

Problem

The functionality worked perfectly for about a month, but starting about a week ago, it began returning the following error:

[error] => Array
(
    [code] => 403
    [message] => The caller does not have permission
    [errors] => Array
    (
        [0] => Array
        (
            [message] => The caller does not have permission
            [domain] => global
            [reason] => forbidden
        )
    )
    [status] => PERMISSION_DENIED
)

What’s Strange

The most puzzling aspect is that no changes were made to GCP or PHP configurations, yet this error suddenly appeared.

What I’ve Tried

I attempted the following solutions, but none resolved the issue:

  • Regenerated the service account private key associated with the GCP service account
  • Created a completely new service account and generated a new private key
  • Changed the root Google account entirely

Additional Testing and Verification

I have also confirmed the following to rule out common issues:

  • Read operations work perfectly - GET requests to retrieve data from specific sheets work without any problems
  • APIs are properly enabled - I have double-checked that both Google Sheets API and Google Drive API are enabled in the Google Cloud Console

My Theory and Confusion

I initially suspected that my Google account was somehow being blocked (403), so I switched to a different Google account. However, the 403 error persisted even with the new account.

This is extremely puzzling. Could it be that GCP is implementing some kind of control per IP address rather than per Google account?

Request for Help

I would appreciate any insights, no matter how small, regarding the root cause and potential solutions for this issue.

Thank you in advance for your assistance.

1 Like

Service accounts shouldn’t be used to create Workspace resources. Instead use an actual user account via OAuth.

Is there a change that Google rolled out recently that would prohibit this? We too have a service user that creates spreadsheets via the Sheets API in our workspace. It had been working fine but suddenly stopped working a couple weeks ago. We have been going in circles trying to find out why we’re suddenly getting “The caller does not have permission” errors. Oddly, another project that uses a different service worker user is still working.