对于 PHP 应用程序中的 Cloud Speech-To-Text 客户端身份验证,我使用以下内容:
$credentials = 'C:\cred.json';
$client=new SpeechClient(['credentials'=>json_decode(file_get_contents($credentials), true)]);
由于某些原因我收到错误:
Fatal error: Uncaught GuzzleHttp\Exception\ClientException: Client error:
POST https://oauth2.googleapis.com/token
resulted in a400 Bad Request
response: {"error":"invalid_scope","error_description":"Invalid OAuth scope or ID token audience provided."}
上述身份验证方法在 Text-To-Speech API 中完美运行。
$credentials = 'C:\cred.json';
$client = new TextToSpeechClient(['credentials' => json_decode(file_get_contents($credentials), true)]);
有什么问题/缺失?
最佳答案
通过更新 Auth 模块(在 Vendor 文件夹中)解决了这个问题。只需将您的 Auth 版本更改为您的 composer.json 文件中的最新版本即可。
{
"require": {
"google/auth": "1.14.3",
"google/cloud-text-to-speech": "^0.5.0",
"google/cloud-speech": "^1.3",
"google/protobuf": "^3.14",
"phpmailer/phpmailer": "^6.1",
"google/apiclient": "2.5"
}
}
一旦完成,我就跑
composer update
在适当目录中的命令行中。现在可以了。
关于php - 如何在 PHP 应用程序中验证 Google Cloud Speech-To-Text 客户端?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/65191899/