【发布时间】:2021-01-15 03:18:42
【问题描述】:
我们在 App Engine 标准 Python 2.7 中有一个应用程序。我们在这个项目中还有一个 Cloud Function。
我们想向 App Engine 应用程序中的资源之一发出 HTTP POST 请求。目前我们在 Cloud Functions 中有以下代码
url = "https://project-name.appspot.com/urlidentifier"
data_obj = {
'sample' : 'data'
}
data_json = json.dumps(data_obj)
data_encode = urllib.parse.urlencode(data_json).encode("utf-8")
req = request.Request(url, data=data_encode) # this will make the method "POST"
resp = request.urlopen(req)
Python 2.7 中的应用程序使用 Firebase 用户身份验证进行身份验证。详情请见here。
我们的问题 - 当 HTTP POST 由 Cloud Function(而不是用户)发起时,我们如何强制对应用程序的资源进行身份验证。应用程序资源 (https://project-name.appspot.com/urlidentifier) 是项目中的一个函数。我们可以使用服务帐户吗?如果是,我们该怎么做?
Cloud Function 和应用程序属于同一个项目。
【问题讨论】:
标签: google-cloud-platform google-cloud-functions google-authentication google-app-engine-python