【发布时间】:2021-01-31 03:51:11
【问题描述】:
我在 powershell 中使用谷歌文本转语音 API。我已经创建了项目,启用了 api,创建了密钥,当我告诉它时 $cred = gcloud auth 应用程序默认打印访问令牌 $headers = @{ "授权" = "承载 $cred" }
Invoke-WebRequest -Method POST
-标头 $标头-ContentType: "application/json; charset=utf-8"
-InFile request.json `
-Uri“https://texttospeech.googleapis.com/v1/text:synthesize”|选择对象-展开内容
这是在我设置环境后,我收到此错误消息 错误:(gcloud.auth.application-default.print-access-token)无法自动确定凭据。请设置 GOOGLE_APPLICATION_CREDENTIALS 或显式创建凭据并重新运行应用程序。欲了解更多信息,请参阅https://cloud.google.com/docs/authentication/getting-started Invoke-WebRequest :远程服务器返回错误:(403) Forbidden。 在 line:4 char:1
- 调用-WebRequest `
-
+ CategoryInfo : InvalidOperation: (System.Net.HttpWebRequest:HttpWebRequest) [Invoke-WebRequest], WebExc eption + FullyQualifiedErrorId : WebCmdletWebResponseException,Microsoft.PowerShell.Commands.InvokeWebRequestCommand
我试图重新创建可能是问题的关键思想,但无论我做什么,我都会在这里不断收到此错误,我正在使用此代码指向关键 $env:GOOGLE_APPLICATION_CREDENTIALS=C:\IVR2\IVR2-ba991f7cce6a.json
【问题讨论】: