【发布时间】:2018-10-16 11:53:37
【问题描述】:
我正在尝试在 Windows 上设置 Google Cloud Api。我花了很多时间来解决这个问题阅读所有相关问题没有任何帮助! 首先我设置变量
set GOOGLE_APPLICATION_CREDENTIALS="C:\Users\Desktop\directory\filename.json"
curl -H "Authorization: Bearer "$(gcloud auth application-default print-access-token) \
-H "Content-Type: application/json; charset=utf-8" \
--data "{
'input':{
'text':'Android is a mobile operating system developed by Google,
based on the Linux kernel and designed primarily for
touchscreen mobile devices such as smartphones and tablets.'
},
'voice':{
'languageCode':'en-gb',
'name':'en-GB-Standard-A',
'ssmlGender':'FEMALE'
},
'audioConfig':{
'audioEncoding':'MP3'
}
}" "https://texttospeech.googleapis.com/v1/text:synthesize" > synthesize-text.txt
如谷歌文档中所述。但是在命令行中
curl: (6) cloud not resolve host: auth curl:(6)云不解析主机:应用程序默认 curl:(6)云无法解析主机:print-access-token
告诉我这个错误。在 synthesize-text.txt 中说错误代码 401。
我该如何解决这个问题。任何帮助表示赞赏。
编辑: 当我原谅
gcloud auth application-default print-acces-token 命令返回环境变量不存在!但是我执行了 set 命令。我究竟做错了什么 ?
【问题讨论】:
标签: json curl http-status-code-401 google-cloud-sdk