【发布时间】:2023-04-01 22:44:01
【问题描述】:
对于 PHP 应用程序中的 Cloud Speech-To-Text 客户端身份验证,我使用以下内容:
$credentials = 'C:\cred.json';
$client=new SpeechClient(['credentials'=>json_decode(file_get_contents($credentials), true)]);
由于某些原因,我收到错误:
致命错误:未捕获的 GuzzleHttp\Exception\ClientException:客户端 错误:
POST https://oauth2.googleapis.com/token导致400 Bad Request响应: {"error":"invalid_scope","error_description":"无效的 OAuth 范围或 提供了 ID 令牌受众。"}
上述身份验证方法在 Text-To-Speech API 中完美运行。
$credentials = 'C:\cred.json';
$client = new TextToSpeechClient(['credentials' => json_decode(file_get_contents($credentials), true)]);
出了什么问题/遗漏了什么?
【问题讨论】:
-
我遇到了同样的问题,但在我的情况下是相反的。 Speech-To-Text 就像一个魅力,但 Text-To-Speech 会产生你提到的错误。你解决了吗?
标签: php google-authentication google-speech-api google-speech-to-text-api