我已经改变了我的方法并转向了之前有效的方法。我配置了一个 API 网关来调用 Google Cloud Functions,当我传入一个 api 密钥时,它以适当的权限调用它们。我认为尝试调用工作流时出错,因为我没有指定资源。虽然不确定...看起来 API 密钥正在工作,但 OAuth 失败了。自从我创建了工作流程以来,我的 OAuth 配置了新的连接。它在我的最后经过身份验证,我在谷歌点击了我的帐户和所有内容。我 99.99% 确定 OAuth 配置正确。当我使用 API Gateway 调用 GCP 函数时,我不必使用 OAuth。
OAuth 是 Workflows API 的一项要求吗?有解决办法吗?
如何在 API Gateway 配置中指定工作流的参数?
命名凭证:
Label GoogleCloudFunction
Name GoogleCloudFunction
URL https://workflowexecutions.googleapis.com
Hide Section - AuthenticationAuthentication
Certificate
Identity Type Named Principal
Authentication Protocol OAuth 2.0
Authentication Provider GoogleCloudAuth
Scope https://www.googleapis.com/auth/cloud-platform
Authentication Status Authenticated
来自 API 网关的日志:
httpRequest: {
latency: "0.039s"
protocol: "http"
requestMethod: "POST"
requestSize: "1269"
requestUrl: "/create-site-tracker-site?key=HIDDEN"
responseSize: "743"
status: 401
}
insertId: "48330ec2-7114-4270-b465-68ae6308bdc34850908905639612439@a1"
jsonPayload: {
api_key: "HIDDEN"
api_key_state: "VERIFIED"
api_version: "1.0.0"
http_status_code: 401
location: "us-central1"
log_message: "1.create_site_tracker_site_0s5865srg8pbr_apigateway_quick_hangout_329722_cloud_goog.CreateSiteFunction is called"
response_code_detail: "via_upstream"
}
API 配置
# openapi2-functions.yaml
swagger: '2.0'
info:
title: create-site-tracker-site with auth
description: Create Site in Site Tracker using JSForce
version: 1.0.0
schemes:
- https
produces:
- application/json
paths:
/create-site-tracker-site:
post:
summary: Create Site
operationId: createSiteFunction
x-google-backend:
address: https://workflowexecutions.googleapis.com/v1/projects/us-central1-quick-hangout-329722/locations/us-central1/workflows/create-site-and-project/executions
security:
- api_key: []
responses:
'200':
description: A successful response
schema:
type: string
securityDefinitions:
# This section configures basic authentication with an API key.
api_key:
type: "apiKey"
name: "key"
in: "query"