多个身份验证“或”无法在Google Cloud Endpoints OpenAPI中运行

时间:2018-01-09 18:31:25

标签: swagger google-cloud-endpoints openapi

在Google Cloud Endpoints中,我无法在“或”方案中进行身份验证,例如,我希望允许通过api_key“或”oauth访问路径。有关详细信息,请参阅https://swagger.io/docs/specification/2-0/authentication/

工作(API密钥的单一定义)

/api/query:
  get:
  operationId: queryget
  responses:
    '200':
      description: query success
  security:
     - api_key: []

工作(oauth的单一定义)

/api/query:
  get:
  operationId: queryget
  responses:
    '200':
      description: query success
  security:
     - oauth: []

是否工作(“和”定义两者都必须包含在身份验证中)

/api/query:
  get:
  operationId: queryget
  responses:
    '200':
      description: query success
  security:
     - oauth: []
       api_key: []

不工作(“或”定义)

/api/query:
  get:
  operationId: queryget
  responses:
    '200':
      description: query success
  security:
     - oauth: []
     - api_key: []

在将我的api部署到Google Cloud Endpoints时更具体,我收到以下警告

Operation 'get' in path '/api/query': Operation does not require an API key; callers may invoke the method without specifying an associated API-consuming project. 

并且,当尝试使用API​​密钥调用api时,我收到以下错误,好像它期待OAUTH JWT令牌(可能因为它是该路由列表中的第一个安全定义)

{ "code": 16, "message": "JWT validation failed: Missing or invalid credentials", "details": [  {   "@type": "type.googleapis.com/google.rpc.DebugInfo",   "stackEntries": [],   "detail": "auth"  } ]}' 

1 个答案:

答案 0 :(得分:2)

遗憾的是,此功能不受支持。您只能使用AND。现在记录在Unsupported OpenAPI Features