- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我正在尝试使用 firebase 身份验证的 GCP API Gateway。我可以看到我的请求已从日志中处理并完成,响应代码为 200。但是,我没有将响应返回给我的客户。当我直接调用该函数时,我得到了响应。我错过了什么吗?
API 配置
swagger: "2.0"
info:
title: API Endpoints
description: API Endpoints
version: 1.0.1
schemes:
- https
produces:
- application/json
securityDefinitions:
firebase:
authorizationUrl: ""
flow: "implicit"
type: "oauth2"
x-google-issuer: "https://securetoken.google.com/my-project"
x-google-jwks_uri: "https://www.googleapis.com/service_accounts/v1/metadata/x509/securetoken@system.gserviceaccount.com"
x-google-audiences: "my-project"
paths:
/hello:
get:
summary: Test link
operationId: hello
x-google-backend:
address: https://us-central1-my-project.cloudfunctions.net/hello
security:
- firebase: []
responses:
"200":
description: A successful response
schema:
type: string
"403":
description: Failed to authenticate
功能
* Responds to any HTTP request.
*
* @param {!express:Request} req HTTP request context.
* @param {!express:Response} res HTTP response context.
*/
exports.helloWorld = (req, res) => {
let message = req.query.message || req.body.message || 'Hello World!';
res.status(200).send(message);
};
日志
allUsers
,它给了我 200。与
Cloud Functions Invoker
我试图调用的函数的权限。所以我在这里有点困惑。我将 API 网关与
firebase
一起使用的部分原因
auth
是为了保护它免受未经授权的调用。对于
firebase
auth
要工作,我必须添加
allUsers
,公开。我的理解是,API 网关本身就是公共(public)的,而它调用的所有后端服务都是私有(private)的。在这种情况下,任何人都可以直接调用该函数,从而使 API Gateway 无用。如何将后端设置为私有(private)并仅通过 API 网关响应经过身份验证的调用?
{
insertId: "8c13b49c-2752-4216-8188-d445f4724ef14850908905639612439@a1"
jsonPayload: {
api_key_state: "NOT CHECKED"
api_method: "1.myapi.GenerateRTCToken"
api_name: "1.myapi"
api_version: "1.0.1"
client_ip: "999.999.999.999"
http_method: "GET"
http_response_code: 200
location: "us-central1"
log_message: "1.myapi.GenerateRTCToken is called"
producer_project_id: "myproject"
request_latency_in_ms: 161
request_size_in_bytes: 4020
response_size_in_bytes: 579
service_agent: "ESPv2/2.17.0"
service_config_id: "myapi-config"
timestamp: 1606313914.9804168
url: "/generateRTCToken"
}
logName: "projects/myproject/logs/myapi%2Fendpoints_log"
receiveTimestamp: "2020-11-25T14:18:36.521292489Z"
resource: {
labels: {
location: "us-central1"
method: "1.myapi.GenerateRTCToken"
project_id: "myproject"
service: "myapi"
version: "1.0.1"
}
type: "api"
}
severity: "INFO"
timestamp: "2020-11-25T14:18:34.980416865Z"
}
最佳答案
调用Google Cloud Function
来自 Api-Gateway
在不公开的情况下,您可以授予 API-Gateway
使用的服务帐户角色CloudFunctions Invoker
在 Creating an API config (4) :你设置了一个服务账号,记下这个服务账号。
确定服务帐户后,您可以授予它 Cloud Funtions Invoker
服务帐户的角色。对于这些,您可以按照以下步骤操作:
Cloud Functions Invoker
关于google-cloud-platform - API 网关不返回响应,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/64667633/
我创建了一个训练作业,我从大查询中获取数据、执行训练和部署模型。我想在这两种情况下自动开始训练: 向数据集添加了 1000 多个新行 有时间表(例如,每周一次) 我检查了 GCP Cloud Sche
我遇到以下警告: WARNING: You do not appear to have access to project [$PROJECT] or it does not exist. 在本地运行
我正在使用 Google Cloud Platform,我必须使用 java 非 Web 应用程序访问云功能,就像我尝试使用 Google Cloud Storage JSON API 从 Googl
我的问题是第三方开发人员如何通过我的身份平台登录用户?我查看了文档,但一无所获。 本质上,我想将 Identity Platform 用作 OIDC 提供者,但我不知道这是否受支持。 最佳答案 Clo
在我去这里的过去 12 个小时左右: https://console.developers.google.com/apis/credentials?project=MYPROJECTNAME 我只是得
我正在尝试创建一个 python 脚本来在 linux 机器上自动安装和配置某些程序。 我的想法是使用平台和多处理库来询问系统信息(platform.system、platform.linux_dis
我正在尝试创建没有控制台网页的 Google Cloud Platform 项目,因为我考虑创建多个项目。 因为我查了gcloud,目前只支持project describe和list。 https:
我正在使用 Google Cloud Scheduler 调用外部应用程序。 Google Cloud Scheduler 使用 OIDC 身份验证并使用服务帐户。我只能从 Google 服务帐户 U
如何在我的 Google Cloud Platform 帐户上启用 Google Authenticator 双重身份验证?我在 Web 界面中上下查看了“IAM 和管理员”,但没有看到在帐户上启用
我们在 Google Cloud 上设置了一个虚拟机,并希望能够自动或计划打开和关闭它。 我们内部有自动脚本,之后可以完成工作,到目前为止,我在 google 的文献中读到的更多与这些实例有关,但我找
我试图删除一个 GCP 项目,但不断弹出以下错误。 Lien origin You cannot delete this project because it is linked with a Dia
我从 Google Domains 购买了一个域,称为 example.com。 我已订阅 G Suite 基本版并创建了一个 admin@example.com 帐户以在 GCP 上使用,而不是我的
我构建了一个包含许多并行进程的 AI Platform 流水线。每个流程都会在 AI Platform 上启动一个训练作业,如下所示: gcloud ai-platform jobs submit t
我们正在验证函数输入时方法参数不为空,但这不适用于 Platform::String (或 Platform.String ,C# 或 C++ 之间没有区别),因为它们用空实例重载空字符串的语义。 考
这个问题比我想来这里的问题要简单一些,但我一直在努力寻找答案,但我绝对不能—— 谷歌云平台 HTTP 函数是否支持路由参数,如此处? http://expressjs.com/en/guide/rou
我正在使用 Kubernetes,我正在尝试创建一个 ingress resource .我使用以下方法创建它: $ kubectl create -f my-ingress.yaml 我等了一会儿,
我是 Google Cloud 的新手,所以我希望得到一些有关“组织”的指导。 我可以将项目从一个“组织”转移到另一个“组织”吗?我正在我的个人 GSuite 组织下启动一些项目,但我必须将它们转移到
在 GET 操作中,我想从返回的集合中排除具有等于“true”的“存档”字段的实体。 我希望这是我的端点(如/users 或/companies)的默认设置,并且我想避免手动添加 URL 过滤器,如
实例模板对于创建托管实例组至关重要。事实上,托管实例组对于在 GCP 中创建自动扩缩组至关重要。 这个问题是另一个问题 question's answer 的一部分,这是关于构建一个自动缩放和负载平衡
我正在将 GCP 用于多个相同的项目。对于每个新项目我都需要一个1 个 GPU 的配额(Tesla K80)。为了申请增加我的GPU配额,我打开console并导航至“IAM 和管理”>“配额”。我在
我是一名优秀的程序员,十分优秀!