ibm-cloud - 在 IBM OpenWhisk swagger.yaml 文件中应该使用什么来代替用户名和密码?
问题描述
我 fork 这个 repo 用于开发一个使用 IBM Watson 服务的 fb 聊天机器人。在 Swagger.yaml 文件中,传递用户名和密码以对请求进行身份验证,但 IBM 不再使用用户名和密码进行身份验证,而是使用 IAM 密钥和 API 密钥。如何在这个 Swagger.yaml 文件中进行设置?我在下面粘贴了使用用户名和密码的代码部分。
招摇的.yaml
operations:
- verb: post
path: /PATH_NAME
execute:
- invoke:
target-url: 'https://openwhisk.ng.bluemix.net/api/v1/namespaces/' + YOUR_NAMESPACE + '/triggers/' + YOUR_SEQUENCE_NAME
username: YOUR_WSK_USERNAME
password: YOUR_WSK_PASSWORD
verb: keep
cache-response: no-cache
- operations:
- verb: get
path: /YOUR_PATH
execute:
- map:
title: map
inputs:
request:
schema:
type: string
variable: request.uri
outputs:
output:
schema:
type: object
properties:
uri:
type: string
name: uri
variable: message.body
content: application/json
actions:
- set: output.uri
from: request
version: 1.0.0
- invoke:
title: invoke
timeout: 60
verb: POST
cache-response: no-cache
cache-ttl: 900
version: 1.0.0
target-url: 'https://openwhisk.ng.bluemix.net/api/v1/namespaces/' + YOUR_NAMESPACE + '/actions/' + YOUR_TRIGGER_NAME + 'blocking=true'
username: YOUR_WSK_USERNAME
password: YOUR_WSK_PASSWORD
output: whisk
我使用以下命令获取我的 WSK 用户名和密码,
bx wsk property get
我找回了这些细节,
client cert
Client key
whisk auth <<some random alpha numeric numbers here>>
whisk API host eu-gb.functions.cloud.ibm.com
whisk API version v1
whisk namespace _
whisk CLI version 2019-01-16T22:06:45+00:00
whisk API build 2019-02-17T08:32:41Z
whisk API build number whisk-build-xxxxx
我找不到这个 WSK 密码或用户名在哪里!
当我尝试将此文件上传到 API-connect 中的 Drafts>API 时,我也遇到了这个错误。
错误
处理 HTTP 请求时发生 JSON 处理异常。有关详细信息,请参阅其他错误消息。消息:意外字符('s'(代码 115)):在 [Source: java.io.ByteArrayInputStream@2335f3d1 ; 行:1,列:2],来源:swagger.yaml,行:1,列:2
处理 HTTP 请求时发生处理异常。有关详细信息,请参阅其他错误消息。
解决方案
推荐阅读
- reactjs - Saga 不断进行相同的 API 调用
- flutter - Flutter Navigator 和 Routing 在单独的文件中显示错误:在 _Widget 中找不到路由 RouteSettings("/details", null) 的生成器
- python - 抑制 pytest6 中特定模块的 DeprecationWarning 无效转义序列
- python - python中是否有一个函数可以将此对象转换为整数
- reactjs - 具有最高值的图表 js 条在其余条中是不同的颜色 - React
- google-apps-script - 在文档中输入模板时,如何在单元格内水平居中文本?
- node.js - 在 joi js .message() 中获取数组键的完整路径
- python - 如何在 1 分钟以下的时间间隔内获得加密货币价格变化(来自 Binance)?
- android-studio - 如何列出文件夹中的文件以查看要打开的文件是否存在?在科特林
- node.js - app.use(express.urlencoded({extended:false})) 在提交时抛出错误