如文档中所述,我已经设置了云帐户并激活了对话流 API。然后我在我的 dialogflow.com 帐户中激活了 dialogflow V2,并在其中设置了相同的 google 项目。
我以 JSON 格式下载了 google 凭据,并相应地设置了它的身份验证路径。
做完这一切之后,当我跑
from google.cloud import storage
storage_client = storage.Client()
buckets = list(storage_client.list_buckets())
print(buckets)
它给了我错误,
OSError: Project was not passed and could not be determined from the environment.
因此,我在存储客户端本身中设置了项目名称。
storage_client = storage.Client(project='[Project-id]')
因此,这解决了代码的问题,但我认为它应该自己检测到项目 ID,而不必提供文档中给出的项目 ID。
毕竟,我尝试运行以下程序来检查连接,
import dialogflow_v2beta1
client = dialogflow_v2beta1.AgentsClient()
parent = client.project_path('[Project-id]')
response = client.import_agent(parent)
def callback(operation_future):
result = operation_future.result()
response.add_done_callback(callback)
metadata = response.metadata()
在此之后我收到以下错误,
PermissionDenied: 403 Dialogflow API has not been used in project usable-auth-library before or it is disabled. Enable it by visiting https://console.developers.google.com/apis/api/dialogflow.googleapis.com/overview?project=usable-auth-library then retry. If you enabled this API recently, wait a few minutes for the action to propagate to our systems and retry.
任何帮助,将不胜感激。