I'm attempting to use Google's Natural Language API for PHP, and having followed the instructions, I'm getting an error in the application I've written:
Fatal error: Uncaught Google\Cloud\Core\Exception\ServiceException: { "error": { "code": 403, "message": "The request is missing a valid API key.", "status": "PERMISSION_DENIED" } }
I've downloaded the account key file, run the export, but I get the 403 error.
I've created a symbolic link to the file in the project folder, run the export, but I get the 403 error.
I placed the export in the ".bash_profile" file, exited the terminal session, but I get the 403 error.
Provide authentication credentials to your application code by setting the environment variable GOOGLE_APPLICATION_CREDENTIALS. Replace [PATH] with the file path of the JSON file that contains your service account key, and [FILE_NAME] with the filename. This variable only applies to your current shell session, so if you open a new session, set the variable again.
When I ran: echo $GOOGLE_APPLICATION_CREDENTIALS
the export isn't there, so I ran it again, but I get the 403 error.
I followed the documentation to the letter, and I've gone through it three times, and each time I get the same 403 error.
I see no instructions asking me to store a string value for the API key in the application, but I've found a number of people recommending that, but not provide an example of how or where.
So, some advice would be welcome!