首页 > 解决方案 > 在 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 请求时发生处理异常。有关详细信息,请参阅其他错误消息。

标签: ibm-cloudibm-watsonswagger-2.0apiconnect-test-monitor

解决方案


推荐阅读