Can't get api key required to work

I can not seem to get the api keys required to work. Sometime the Any proxy will work but no other functions.

Any help is appreciated.

Here is my serverless.yml.

serverless.yml

service: xxxxx-api

plugins:

  • serverless-offline
  • serverless-domain-manager

provider:
name: aws
runtime: nodejs8.10
stage: dev
region: us-west-1

resources:
Resources:
MyServiceUsagePlan:
Type: “AWS::ApiGateway::UsagePlan”
DependsOn: ApiGatewayRestApi
Properties:
UsagePlanName: xxxxx-api-dev

MyServiceUsagePlanKey:
  Type: "AWS::ApiGateway::UsagePlanKey"
  DependsOn: MyServiceUsagePlan
  Properties :
    KeyId: xxx4impug7
    KeyType: API_KEY
    UsagePlanId:
      Ref: MyServiceUsagePlan

functions:
app:
handler: index.handler
events:
- http: ANY /
- http: ‘ANY {proxy+}’
private: true

basicOrder:
handler: index.handler
events:
- http: ‘POST /basicOrder’
private: true

gettoken:
handler: index.handler
events:
- http: ‘POST /client/getToken’
private: true

custom:
customDomain:
domainName: apidev.myxxxxxtech.io
basePath: ‘’
stage: ${self:provider.stage}
createRoute53Record: true

I think you’re indentation is incorrect for private: true. Try something like:

  gettoken:
      handler: index.handler
      events:
        - http:
            path: client/getToken
            method: post
            private: true
2 Likes

Thank you so much. I had tried that before to no avail. Must have been something else at the time.