我正在尝试从另一个 GCP 函数 (A) 调用 GCP 函数 (B)。
到目前为止,我已经:
从 google.oauth2 导入 service_account 从 google.auth.transport.requests 导入 AuthorizedSession
function_url = 'https://europe-west6-xxx.cloudfunctions.net/yyy'
json_path = "/Users/xxx44b1.json"
credentials = service_account.IDTokenCredentials.from_service_account_file(
json_path,
target_audience=function_url,
)
authed_session = AuthorizedSession(credentials)
response = authed_session.post(function_url)
response.text
但是,它不起作用,并返回:
<html><head>
<meta http-equiv="content-type" content="text/html;charset=utf-8">
<title>404 Page not found</title>
</head>
<body text=#000000 bgcolor=#ffffff>
<h1>Error: Page not found</h1>
<h2>The requested URL was not found on this server.</h2>
<h2></h2>
</body></html>
我该如何解决这个问题?
您可能需要检查您的入口设置基于文档,如下所示:
gcloud functions deploy FUNCTION_NAME
--trigger-http
--ingress-settings INGRESS_SETTINGS