# Can't get api key required to work

**URL:** <https://forum.serverless.com/t/cant-get-api-key-required-to-work/4546>\
**Category:** Serverless Framework\
**Created:** [May 21, 2018, 9:01pm UTC](https://forum.serverless.com/t/cant-get-api-key-required-to-work/4546 "2018-05-21T21:01:05Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![cogear](https://avatars.discourse-cdn.com/v4/letter/c/51bf81/32.png) [@cogear](https://forum.serverless.com/u/cogear)\
**Post date:** [May 21, 2018, 9:01pm UTC](https://forum.serverless.com/t/cant-get-api-key-required-to-work/4546/1 "2018-05-21T21:01:05Z")

</div>

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](http://apidev.myxxxxxtech.io)  
basePath: ‘’  
stage: ${self:provider.stage}  
createRoute53Record: true

---

<div class="post-metadata">

**Author:** ![buggy](https://yyz2.discourse-cdn.com/flex036/user_avatar/forum.serverless.com/buggy/32/177_2.png) [@buggy](https://forum.serverless.com/u/buggy)\
**Post date:** [May 22, 2018, 10:55am UTC](https://forum.serverless.com/t/cant-get-api-key-required-to-work/4546/2 "2018-05-22T10:55:13Z")

</div>

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

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

```

---

<div class="post-metadata">

**Author:** ![cogear](https://avatars.discourse-cdn.com/v4/letter/c/51bf81/32.png) [@cogear](https://forum.serverless.com/u/cogear)\
**Post date:** [May 22, 2018, 1:39pm UTC](https://forum.serverless.com/t/cant-get-api-key-required-to-work/4546/3 "2018-05-22T13:39:38Z")

</div>

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