我已经改变了我的方法,转向以前有效的方法。我配置了一个API网关来调用Google Cloud Functions,当我传入API密钥时,它会以适当的权限调用它们。我认为这是错误的,当试图调用工作流,因为我没有指定资源。不过不太确定……看起来API密钥正在工作,但是OAuth失败了。我的OAuth配置了一个新的连接,因为我已经创建了工作流。我这边是经过认证的,我在谷歌上点击了我的账户。我99.99%确定OAuth配置正确。当我用API网关调用GCP函数时,我不必使用OAuth。
-
OAuth是工作流API的要求吗?有什么变通的办法吗?
-
如何在API网关配置中指定工作流的参数?
命名凭据:
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"
当前的工作是从google云函数调用工作流,然后通过API网关调用该函数并传递一个密钥。很恶心,但它有效