请求的身份验证范围不足

Request had insufficient authentication scopes

我正在尝试 运行 在 dataproc master-node 上使用 gcloud 的 pyspark 应用程序。我得到 "Request had insufficient authentication scopes"

# gcloud dataproc jobs submit pyspark --cluster xxxxx test.py

gcloud.dataproc.jobs.submit.pyspark) You do not have permission 
to access        cluster [xxxxxx] (or it may not exist): 
Request had  insufficient authentication scopes

我可以通过 Jobs GUI 运行 相同的应用程序。我现在没有 link 文档,但它说如果这是 运行 在 Compute VM 上,则不需要单独的凭据,这似乎与我 运行 使用相同的应用程序时一致图形用户界面。有帮助吗?

当来自 Dataproc 节点的 运行 时,您将代表 service account attached to the VM. Usually you'll be using a default compute engine service account, but this can also be specified with the Dataproc service account configuration。除了服务帐户之外,还有一个 scopes 列表,它限制了允许该服务帐户从该 VM 访问哪些 GCP 服务。默认情况下,有 BigQuery、GCS、日志记录和其他一些小范围,但没有用于创建其他 VM 或 Dataproc 集群等操作的一般管理范围。

要授予必要的范围,您必须在首次创建集群时添加 --scopes

gcloud dataproc clusters create --scopes cloud-platform ...