Text To Speech

⌘K
  1. Home
  2. Docs
  3. Text To Speech
  4. Usage & Setup
  5. Fixing Google Cloud Storage Error: ‘Permission Denied for storage.buckets.get’ in PHP

Fixing Google Cloud Storage Error: ‘Permission Denied for storage.buckets.get’ in PHP

The error message you’re encountering suggests that the Google Cloud service account (xxxxx@xxxxxxxxx.iam.gserviceaccount.com) doesn’t have the necessary permissions to access the specified Google Cloud Storage bucket. Specifically, the permission 'storage.buckets.get' is missing, which is required to access or retrieve information about the bucket.

PHP Fatal error: Uncaught Google\Cloud\Core\Exception\ServiceException: {"error":{"code":403,"message":"tts-655@sunny-wavelet-424212-s5.iam.gserviceaccount.com does not have storage.buckets.get access to the Google Cloud Storage bucket. Permission 'storage.buckets.get' denied on resource (or it may not exist).","errors":[{"message":"tts-655@sunny-wavelet-424212-s5.iam.gserviceaccount.com does not have storage.buckets.get access to the Google Cloud Storage bucket. Permission 'storage.buckets.get' denied on resource (or it may not exist).","domain":"global","reason":"forbidden"}]}}

Here are the steps to resolve this issue:

1. Grant Permissions to the Service Account

You need to ensure that the service account has the required permissions to access the Cloud Storage bucket.

a. Identify the correct bucket

Make sure that the bucket you’re trying to access exists and that you have the right bucket name.

b. Assign Storage Object Viewer or Storage Admin role

  1. Go to the Google Cloud Console: https://console.cloud.google.com/.
  2. Navigate to IAM & Admin > IAM.
  3. Find the service account (xxxxx@xxxxxxxxx.iam.gserviceaccount.com) in the list.
  4. Click Edit (the pencil icon) next to the service account.
  5. In the Role section, click + Add another role.
  6. Select either:
  • Storage Object Viewer: If you just need read-only access.
  • Storage Admin: If you need full access to manage storage buckets.
  1. Save the changes.

c. Verify that the correct project is being used

Ensure that the service account is accessing the correct Google Cloud project where the bucket resides.

2. Verify the Storage Bucket Exists

Make sure the Google Cloud Storage bucket you’re trying to access exists in the project. You can verify this by going to Cloud Storage in the Google Cloud Console and checking the list of buckets.

3. Double-check Bucket Policies

If the bucket has any special policies or access controls, ensure that the service account is included in these policies with the necessary permissions.

Once the correct permissions are set, the error should be resolved. Let me know if you need further assistance!

How can we help?