Get hands-on experience with 20+ free Google Cloud products and $300 in free credit for new customers.

Text to speech (PHP) 403 error

We've been using the text-to-speech PHP client for several years now, but the service has suddenly stopped working for some unknown reason (my code remains the same). Our server error log is showing the following message:

PHP Fatal error: Uncaught Google\ApiCore\ApiException: {
"message": "<!DOCTYPE html> ..... Error 403 (Forbidden) .... in /vendor/google/gax/src/ApiException.php on line 139

We are authenticating with a Service Account that looks like this in our PHP script: "putenv(Google_Application_Credentials=XXXX.json);"

This method used to work without issues, but maybe something has changed in the GCP authentication method?

1 2 1,041
2 REPLIES 2

A few days later, the same code no longer throws any errors, and everything works as expected.

It appears that Google fixed whatever they had broken, but we've wasted hours trying to find out what was going on with our Text-To-Speech implementation. Next time, it would be nice to receive at least a notification when their cloud services are temporarily interrupted for some reason.

The error message you're encountering, "Error 403 (Forbidden)," indicates that your PHP application is unable to authenticate with the Google Cloud service, resulting in a permission issue. Since it has been fixed, there are a few potential reasons for this sudden issue:

1. Google Cloud Platform (GCP) might have made changes to authentication requirements or permissions.

2. It's possible that the underlying Google API client libraries or dependencies have been updated, which may affect the behavior of your application. 

Service disruptions or issues can indeed be challenging to diagnose and resolve, especially when they are caused by factors beyond your control, such as changes or disruptions on the service provider's end.

You can check the status page since it provides real-time information about service disruptions, incidents, and maintenance.