I created open API by using Nodejs and deploy on google cloud endpoints also trying to implement securing this API by using an API key.
Then, I created openapi.yaml file added security definition in the bottom that is :
# [START securityDef]
securityDefinitions:
# This section configures basic authentication with an API key.
api_key:
type: "apiKey"
name: "X-API-KEY"
in: "query"
# [END securityDef]
And Under the path added security:
"/api/getProduct":
get:
description: "Get product data."
operationId: "getProduct"
produces:
- "application/json"
responses:
200:
description: "getProduct"
schema:
$ref: "#/definitions/echoMessage"
security:
- api_key: []
After this, when I'm deploying the endpoint getting the message as shown in below image:
Now, I'm unable to understand what to do next?
Please, anyone can help me on the same. Thanks in advance.
I was able to get the same error message using the sample configuration provided in the nodejs code samples by setting the api_key.name
value to X-API-KEY
, instead of key
, like you did.
Apparently the Cloud Endpoints Portal requires it to be set to key
, as once I switched back it worked as expected. Like the example below:
securityDefinitions:
api_key:
type: "apiKey"
name: "key"
in: "query"