0

我正在尝试从 dataproc 访问存储在 GC Secret Manager 中的机密,但我无法这样做。我已启用 Secrets Manager api 并将 Secret Manager Secret Accessor 的 IAM 角色添加到我的所有者帐户和数据过程中。但是我正在尝试创建/访问机密,但出现以下错误:

PermissionDenied:403 请求的身份验证范围不足。

我正在关注此处提供的以下教程[https://cloud.google.com/secret-manager/docs/creating-and-accessing-secrets?authuser=3]

这是代码片段:

def create_secret(project_id, secret_id):
"""
Create a new secret with the given name. A secret is a logical wrapper
around a collection of secret versions. Secret versions hold the actual
secret material.
"""

# Import the Secret Manager client library.
from google.cloud import secretmanager

# Create the Secret Manager client.
client = secretmanager.SecretManagerServiceClient()

# Build the resource name of the parent project.
parent = f"projects/{project_id}"

# Create the secret.
response = client.create_secret(
    request={
        "parent": parent,
        "secret_id": secret_id,
        "secret": {"replication": {"automatic": {}}},
    }
)

# Print the new secret name.
print("Created secret: {}".format(response.name))
4

0 回答 0