我正在PowerApps中创建一个需要调用API的自定义连接器。API需要传递一个授权令牌。通过Postman发送请求,设置如下:授权:Bearer 2b3fdha04a4d89aad9c263d5d716bcc379aff0008
当我尝试通过Swagger做同样的事情时,头部会像这样发送:Access-Control-Request-Headers:授权
这就是我试图传递令牌的方式:
- {name: Authorization, in: header, description: This is the API key, required: true, type: string}
这是我完整的Swagger定义文件:'
swagger: '2.0'
info: {version: 1.0.0, title: ACME Corp, description: ACME sample API}
host: acmeapis.com
basePath: /
schemes: [https]
consumes: [multipart/form-data]
produces: [application/json]
securityDefinitions: {}
paths:
/v4_server/external/v1/authenticate:
post:
summary: Authorize
description: Used to get an authorization token
operationId: Authorize
parameters:
- {in: formData, name: api_key, type: string, description: The API key., required: true}
- {in: formData, name: client_db, type: string, description: The database to use.,
required: true}
- {in: formData, name: username, type: string, description: The username, required: true}
responses:
default:
description: All is well
schema:
type: object
properties:
access_token: {type: string, description: access_token}
expires_in: {type: integer, format: int32, description: expires_in}
refresh_token: {type: string, description: refresh_token}
/v4_server/external/v1/maintenance/resources/properties:
get:
summary: Building/Property Location
- Bearer: []
description: Building/Property Location
operationId: Building_propertyLocation
parameters:
- {name: property_use_id, default: '2', in: query, type: string, required: true}
- {name: $orderBy, default: unit, in: query, type: string, required: true}
- {name: Authorization, in: header, description: This is the API key, required: true, type: string}
responses:
'200': {description: Will send `Authenticated`}
'403': {description: 'You do not have necessary permissions for the resource,'}
default:
description: default
schema: {}
/: {}
definitions: {}
parameters: {}
responses: {}
security: []
tags: []
我找不到任何关于如何做这件事的例子。谁能给我指一下路?
谢谢
<代码>代码>
在模式
下添加以下行swagger: '2.0'
info: {version: 1.0.0, title: ACME Corp, description: ACME sample API}
host: acmeapis.com
basePath: /
schemes: [https]
securityDefinitions:
Bearer:
type: apiKey
name: Authorization
in: header
description: >-
Enter the token with the `Bearer: ` prefix, e.g. "Bearer abcde12345".
consumes: [multipart/form-data]
produces: [application/json]
paths:
/v4_server/external/v1/authenticate:
post:
summary: Authorize
description: Used to get an authorization token
operationId: Authorize
parameters:
- {in: formData, name: api_key, type: string, description: The API key., required: true}
- {in: formData, name: client_db, type: string, description: The database to use.,
required: true}
- {in: formData, name: username, type: string, description: The username, required: true}
responses:
default:
description: All is well
schema:
type: object
properties:
access_token: {type: string, description: access_token}
expires_in: {type: integer, format: int32, description: expires_in}
refresh_token: {type: string, description: refresh_token}
/v4_server/external/v1/maintenance/resources/properties:
get:
summary: Building/Property Location
description: Building/Property Location
operationId: Building_propertyLocation
parameters:
- {name: property_use_id, default: '2', in: query, type: string, required: true}
- {name: $orderBy, default: unit, in: query, type: string, required: true}
- {name: Authorization, in: header, description: This is the API key, required: true, type: string}
responses:
'200': {description: Will send `Authenticated`}
'403': {description: 'You do not have necessary permissions for the resource,'}
default:
description: default
schema: {}
/: {}
definitions: {}
parameters: {}
responses: {}
security: []
tags: []
这是你的完整的swagger(我已经在swagger编辑器上测试了它-只需复制并放入它即可查看结果)
PP_5