【发布时间】:2018-05-30 06:35:03
【问题描述】:
我不知道如何将身份验证/凭据传递给我从我的 python 程序运行的谷歌云 api 帖子
import requests
api_endpoint = "https://dataflow.googleapis.com/v1b3/projects/projectid/templates"
data = {
"jobName": "scriptjob2",
"parameters": {
"inputFilePattern": "gs://bucket/files/*.json",
"outputTopic": "projects/project6/topics/data"
},
"environment": {
"tempLocation": "gs://bucket/tmp",
"zone": "us-central1-f"
},
"gcsPath": "gs://dataflow-templates/latest/GCS_Text_to_Cloud_PubSub",
"location": "us-central1"
}
r = requests.post(url = api_endpoint, data = data)
result = r.text
print("Result:%s"%result)
我知道我应该通过 google 服务帐户身份验证,但我就是不知道该怎么做。这是我收到的错误消息。
"error": {
"code": 401,
"message": "Request is missing required authentication credential. Expected OAuth 2 access token, login cookie or other v
alid authentication credential. See https://developers.google.com/identity/sign-in/web/devconsole-project.",
"status": "UNAUTHENTICATED"
}
}
【问题讨论】:
标签: python post get google-cloud-platform