Authentication 如何排除';文件…不存在';gcloud中出现错误(代码403)
我试图从中执行一些示例代码,将示例音频文件转换为文本,但收到的错误消息毫无意义 我已经完成了指示的所有步骤:Authentication 如何排除';文件…不存在';gcloud中出现错误(代码403),authentication,google-cloud-platform,google-cloud-speech,Authentication,Google Cloud Platform,Google Cloud Speech,我试图从中执行一些示例代码,将示例音频文件转换为文本,但收到的错误消息毫无意义 我已经完成了指示的所有步骤: 创建项目 启用语音到文本API 创建服务帐户 将私钥下载为JSON文件 我打开终端(版本2.9.4(421.1.1))MacOS 10.14.4 我执行以下代码以设置环境变量: 导出GOOGLE\u应用程序\u凭据=“[PATH]”(路径是我下载的JSON文件的位置) 然后,我创建他们说要创建的JSON请求文件,这基本上就是获取示例音频文件的说明 然后,在初始化gcloud并确保我位于
- 创建项目
- 启用语音到文本API
- 创建服务帐户
- 将私钥下载为JSON文件
- 我打开终端(版本2.9.4(421.1.1))MacOS 10.14.4
- 我执行以下代码以设置环境变量:
(路径是我下载的JSON文件的位置)导出GOOGLE\u应用程序\u凭据=“[PATH]”
- 然后,我创建他们说要创建的JSON请求文件,这基本上就是获取示例音频文件的说明
- 然后,在初始化gcloud并确保我位于包含我创建的JSON请求文件的同一目录中之后,我执行以下代码:
ERROR: (gcloud.auth.application-default.print-access-token) File /pathofFile/nameofFile.json (pointed by GOOGLE_APPLICATION_CREDENTIALS environment variable) does not exist!
{
"error": {
"code": 403,
"message": "The request is missing a valid API key.",
"status": "PERMISSION_DENIED"
}
}
这个错误显然不是因为我没有设置环境变量,因为错误消息是“(由GOOGLE_APPLICATION_CREDENTIALS环境变量指出),”并且错误消息显示了正确JSON凭据文件的正确路径。JSON凭证文件肯定存在;我可以在finder中看到它
这里会出什么问题
编辑:当我尝试跑步时
gcloud auth应用程序默认登录
或
gcloud auth应用程序默认打印访问令牌
,
我收到错误消息gcloud:command not found
所以看起来我没有完全安装云SDK。现在我想知道为了完成这项任务,我需要安装SDK的哪些组件。我需要安装以下哪项
The latest available version is: 246.0.0
┌────────────────────────────────────────────────────────────────────────────────────────────────────────────────┐
│ Components │
├──────────────────┬──────────────────────────────────────────────────────┬──────────────────────────┬───────────┤
│ Status │ Name │ ID │ Size │
├──────────────────┼──────────────────────────────────────────────────────┼──────────────────────────┼───────────┤
│ Update Available │ BigQuery Command Line Tool │ bq │ < 1 MiB │
│ Update Available │ Cloud SDK Core Libraries │ core │ 10.5 MiB │
│ Not Installed │ App Engine Go Extensions │ app-engine-go │ 56.4 MiB │
│ Not Installed │ Cloud Bigtable Command Line Tool │ cbt │ 6.3 MiB │
│ Not Installed │ Cloud Bigtable Emulator │ bigtable │ 5.6 MiB │
│ Not Installed │ Cloud Datalab Command Line Tool │ datalab │ < 1 MiB │
│ Not Installed │ Cloud Datastore Emulator │ cloud-datastore-emulator │ 18.4 MiB │
│ Not Installed │ Cloud Datastore Emulator (Legacy) │ gcd-emulator │ 38.1 MiB │
│ Not Installed │ Cloud Firestore Emulator │ cloud-firestore-emulator │ 40.5 MiB │
│ Not Installed │ Cloud Pub/Sub Emulator │ pubsub-emulator │ 34.8 MiB │
│ Not Installed │ Cloud SQL Proxy │ cloud_sql_proxy │ 3.7 MiB │
│ Not Installed │ Emulator Reverse Proxy │ emulator-reverse-proxy │ 14.5 MiB │
│ Not Installed │ Google Cloud Build Local Builder │ cloud-build-local │ 5.9 MiB │
│ Not Installed │ Google Container Registry's Docker credential helper │ docker-credential-gcr │ 1.8 MiB │
│ Not Installed │ gcloud Alpha Commands │ alpha │ < 1 MiB │
│ Not Installed │ gcloud Beta Commands │ beta │ < 1 MiB │
│ Not Installed │ gcloud app Java Extensions │ app-engine-java │ 105.6 MiB │
│ Not Installed │ gcloud app PHP Extensions │ app-engine-php │ 21.9 MiB │
│ Not Installed │ gcloud app Python Extensions │ app-engine-python │ 6.0 MiB │
│ Not Installed │ gcloud app Python Extensions (Extra Libraries) │ app-engine-python-extras │ 28.5 MiB │
│ Not Installed │ kubectl │ kubectl │ < 1 MiB │
│ Installed │ Cloud Storage Command Line Tool │ gsutil │ 3.8 MiB │
└──────────────────┴──────────────────────────────────────────────────────┴──────────────────────────┴───────────┘
To install or remove components at your current SDK version [245.0.0], run:
$ gcloud components install COMPONENT_ID
$ gcloud components remove COMPONENT_ID
最新可用版本为:246.0.0
┌────────────────────────────────────────────────────────────────────────────────────────────────────────────────┐
│ 组件│
├──────────────────┬──────────────────────────────────────────────────────┬──────────────────────────┬───────────┤
│ 地位│ 名称│ 身份证件│ 大小│
├──────────────────┼──────────────────────────────────────────────────────┼──────────────────────────┼───────────┤
│ 更新可用│ BigQuery命令行工具│ bq│ < 1 MiB│
│ 更新可用│ 云SDK核心库│ 核心│ 10.5 MiB│
│ 未安装│ 应用程序引擎Go扩展│ 应用程序引擎go│ 56.4 MiB│
│ 未安装│ cloudbigtable命令行工具│ cbt│ 6.3管理信息库│
│ 未安装│ 云大表仿真器│ 大桌子│ 5.6 MiB│
│ 未安装│ 云数据实验室命令行工具│ 数据实验室│ < 1 MiB│
│ 未安装│ 云数据存储模拟器│ 云数据存储模拟器│ 18.4管理信息库│
│ 未安装│ 云数据存储模拟器(旧版)│ gcd仿真器│ 38.1 MiB│
│ 未安装│ 云Firestore模拟器│ 云firestore模拟器│ 40.5 MiB│
│ 未安装│ 云发布/订阅模拟器│ pubsub仿真器│ 34.8 MiB│
│ 未安装│ 云SQL代理│ 云sql代理│ 3.7管理信息库│
│ 未安装│ 仿真器反向代理│ 仿真器反向代理│ 14.5 MiB│
│ 未安装│ 谷歌云构建本地构建器│ 云构建本地│ 5.9 MiB│
│ 未安装│ Google容器注册表的Docker凭据助手│ docker凭证gcr│ 1.8 MiB│
│ 未安装│ gcloudalpha命令│ 阿尔法│ < 1 MiB│
│ 未安装│ gcloudbeta命令│ 贝塔│ < 1 MiB│
│ 未安装│ gcloud应用程序Java扩展│ 应用程序引擎java│ 105.6 MiB│
│ 未安装│ gcloud应用程序PHP扩展│ 应用程序引擎php│ 21.9 MiB│
│ 未安装│ gcloud应用程序Python扩展│ 应用程序引擎python│ 6.0 MiB│
│ 未安装│ gcloud应用程序Python扩展(额外库)│ 应用程序引擎python附加程序│ 28.5 MiB│
│ 未安装│ 库贝特尔│ 库贝特尔│ < 1 MiB│
│ 安装│ 云存储命令行工具│
The latest available version is: 246.0.0
┌────────────────────────────────────────────────────────────────────────────────────────────────────────────────┐
│ Components │
├──────────────────┬──────────────────────────────────────────────────────┬──────────────────────────┬───────────┤
│ Status │ Name │ ID │ Size │
├──────────────────┼──────────────────────────────────────────────────────┼──────────────────────────┼───────────┤
│ Update Available │ BigQuery Command Line Tool │ bq │ < 1 MiB │
│ Update Available │ Cloud SDK Core Libraries │ core │ 10.5 MiB │
│ Not Installed │ App Engine Go Extensions │ app-engine-go │ 56.4 MiB │
│ Not Installed │ Cloud Bigtable Command Line Tool │ cbt │ 6.3 MiB │
│ Not Installed │ Cloud Bigtable Emulator │ bigtable │ 5.6 MiB │
│ Not Installed │ Cloud Datalab Command Line Tool │ datalab │ < 1 MiB │
│ Not Installed │ Cloud Datastore Emulator │ cloud-datastore-emulator │ 18.4 MiB │
│ Not Installed │ Cloud Datastore Emulator (Legacy) │ gcd-emulator │ 38.1 MiB │
│ Not Installed │ Cloud Firestore Emulator │ cloud-firestore-emulator │ 40.5 MiB │
│ Not Installed │ Cloud Pub/Sub Emulator │ pubsub-emulator │ 34.8 MiB │
│ Not Installed │ Cloud SQL Proxy │ cloud_sql_proxy │ 3.7 MiB │
│ Not Installed │ Emulator Reverse Proxy │ emulator-reverse-proxy │ 14.5 MiB │
│ Not Installed │ Google Cloud Build Local Builder │ cloud-build-local │ 5.9 MiB │
│ Not Installed │ Google Container Registry's Docker credential helper │ docker-credential-gcr │ 1.8 MiB │
│ Not Installed │ gcloud Alpha Commands │ alpha │ < 1 MiB │
│ Not Installed │ gcloud Beta Commands │ beta │ < 1 MiB │
│ Not Installed │ gcloud app Java Extensions │ app-engine-java │ 105.6 MiB │
│ Not Installed │ gcloud app PHP Extensions │ app-engine-php │ 21.9 MiB │
│ Not Installed │ gcloud app Python Extensions │ app-engine-python │ 6.0 MiB │
│ Not Installed │ gcloud app Python Extensions (Extra Libraries) │ app-engine-python-extras │ 28.5 MiB │
│ Not Installed │ kubectl │ kubectl │ < 1 MiB │
│ Installed │ Cloud Storage Command Line Tool │ gsutil │ 3.8 MiB │
└──────────────────┴──────────────────────────────────────────────────────┴──────────────────────────┴───────────┘
To install or remove components at your current SDK version [245.0.0], run:
$ gcloud components install COMPONENT_ID
$ gcloud components remove COMPONENT_ID