我有一组相互调用的函数,如果我只将它们设置为内部通信,并试图通过URL调用它们,我将得到一个403响应。如果将它们设置为ALLOW_ALL通信量,则可以通过从同级函数调用它们来执行它们。
这就是我试图从兄弟函数(Python)调用函数的方式:
functionURL = os.environ.get("FUNCTION_URL", "")
metadata_server_url = "http://metadata/computeMetadata/v1/instance/service-accounts/default/identity?audience="
token_full_url = metadata_server_url + functionURL
token_headers = {"Metadata-Flavor": "Google"}
# Fetch the token
token_response = requests.get(token_full_url, headers=token_headers)
jwt = token_response.text
# Provide the token in the request to the receiving function
function_headers = {"Authorization": f"bearer {jwt}"}
r = requests.post(functionURL, json=jsonData, headers=function_headers)当函数的入口设置为“只允许内部和GCLB”时,是否有方法在内部调用函数?

发布于 2021-04-21 19:39:32
在您的例子中,您有两个解决方案:
您还可以设置一个“允许所有”,它已经在您的私有函数上工作了。此函数受IAM服务的保护(因为您需要设置JWT Bearer令牌),因此,公共或私有令牌丢失、无效或未经授权,云功能受到保护!
https://stackoverflow.com/questions/67200980
复制相似问题