我正在按照 Google 的教程为我的云功能设置端点。
当我尝试使用 URL 从浏览器访问端点时,service_name.a.run.app/function1
我得到
Error: Forbidden
Your client does not have permission to get URL /function1GET from this server
Run Code Online (Sandbox Code Playgroud)
作为上述教程和Google 产品经理的回答的一部分,我通过授予 ESP 调用我的函数的权限来保护我的函数。
gcloud beta functions add-iam-policy-binding function1 --member "serviceAccount:id-compute@developer.gserviceaccount.com" --role "roles/cloudfunctions.invoker" --project "project_id"
Run Code Online (Sandbox Code Playgroud)
我的openapi-functions.yaml
swagger: '2.0'
info:
title: Cloud Endpoints + GCF
description: Sample API on Cloud Endpoints with a Google Cloud Functions backend
version: 1.0.0
host: HOST
x-google-endpoints:
- name: "HOST"
allowCors: "true
schemes:
- https
produces:
- application/json …
Run Code Online (Sandbox Code Playgroud)