# Can't get custom authorizer to work

**URL:** <https://community.auth0.com/t/cant-get-custom-authorizer-to-work/9873>\
**Category:** Get Help\
**Created:** [March 8, 2018, 12:01pm UTC](https://community.auth0.com/t/cant-get-custom-authorizer-to-work/9873 "2018-03-08T12:01:20Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![gl89](https://upload.wikimedia.org/wikipedia/commons/thumb/7/7c/User_font_awesome.svg/768px-User_font_awesome.svg.png) [@gl89](https://community.auth0.com/u/gl89)\
**Post date:** [March 8, 2018, 12:01pm UTC](https://community.auth0.com/t/cant-get-custom-authorizer-to-work/9873/1 "2018-03-08T12:01:20Z")

</div>

I’ve been following the tutorial for custom authorizers for AWS’ API Gateway here:

> **[Secure AWS API Gateway Endpoints Using Custom Authorizers - Auth0 Docs](https://auth0.com/docs/customize/integrations/aws/aws-api-gateway-custom-authorizers)**
>
> How to use secure AWS API Gateway using custom authorizers that accept Auth0-issued access tokens.

At step three I’m having issues when I run npm test, I get this error returning (I’ve put in xxxxx to replace real info):

_Logs_  
_----_  
_START RequestId: 126370da-b303-e702-e270-606fa50a2e3e_  
_{ type: ‘TOKEN’,_  
\_ authorizationToken: ‘Bearer xxxxxx’,\_  
\_ methodArn: ‘arn:aws:execute-api:ap-southeast-2:xxxxx:xxxxx/\*/GET/pets’ }\_  
_/Users/xxxxx/Downloads/jwt-rsa-aws-custom-authorizer-master/lib.js:53_  
\_ var kid = decoded.header.kid;\_  
\_ ^\_

_TypeError: Cannot read property ‘header’ of null_  
\_ at Object.module.exports.authenticate (/Users/xxxxx/Downloads/jwt-rsa-aws-custom-authorizer-master/lib.js:53:22)\_  
\_ at Object.module.exports.handler (/Users/xxxxx/Downloads/jwt-rsa-aws-custom-authorizer-master/index.js:8:7)\_  
\_ at /Users/xxxxx/Downloads/jwt-rsa-aws-custom-authorizer-master/node\_modules/lambda-local/bin/lambda-local:61:27\_  
\_ at Object. (/Users/xxxxx/Downloads/jwt-rsa-aws-custom-authorizer-master/node\_modules/lambda-local/bin/lambda-local:63:3)\_  
\_ at Module._compile (module.js:409:26)_  
\_ at Object.Module._extensions..js (module.js:416:10)_  
\_ at Module.load (module.js:343:32)\_  
\_ at Function.Module._load (module.js:300:12)_  
\_ at Function.Module.runMain (module.js:441:10)\_  
\_ at startup (node.js:139:18)\_

My .env file looks like this

# copy this file to .env and fill in the

JWKS\_URI=[https://xxxxx.au.auth0.com/.well-known/jwks.json](https://xxxxx.au.auth0.com/.well-known/jwks.json)  
AUDIENCE=[https://xxxxx/](https://xxxxx/)  
TOKEN\_ISSUER=[https://xxxxx.au.auth0.com/](https://xxxxx.au.auth0.com/)

One part I’m not totally sure which may be causing the problem is is the audience line in .env, under my API’s settings in auth0 is this meant to be “Id” eg. the randomly generated Id or the “Identifier”, the URL which you specify when creating the API?

Or is my issue related to something else?

---

<div class="post-metadata">

**Author:** ![richard.dowinton](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/richard.dowinton/32/16150_2.png) [@richard.dowinton](https://community.auth0.com/u/richard.dowinton)\
**Post date:** [March 8, 2018, 5:56pm UTC](https://community.auth0.com/t/cant-get-custom-authorizer-to-work/9873/2 "2018-03-08T17:56:19Z")

</div>

You are correct with regards to the identifier of your API being the audience you should use when you request the access token.

Judging from the error you shared, it seems your authorizer is unable to decode the token. This will only occur if the token is not a valid [JWT](https://auth0.com/docs/jwt). Are you sure that you are in fact sending a JWT and not an opaque access token instead?

Keep in mind that if you haven’t specified an audience or have specified the `userinfo` endpoint as your audience, you will receive an opaque access token rather than a JWT.

---

<div class="post-metadata">

**Author:** ![gl89](https://upload.wikimedia.org/wikipedia/commons/thumb/7/7c/User_font_awesome.svg/768px-User_font_awesome.svg.png) [@gl89](https://community.auth0.com/u/gl89)\
**Post date:** [March 9, 2018, 3:32am UTC](https://community.auth0.com/t/cant-get-custom-authorizer-to-work/9873/3 "2018-03-09T03:32:00Z")

</div>

Hi Richard,

Thanks for the response - its quite strange, the token from the Test page for the API came back as valid but when using that as the Bearer in the event.json file I would get the error above. I performed the cURL command in terminal with the example on the Test page and used the access token from that and npm test then worked.

Strange but I think I can move forward now, thank you for your assistance!

---

<div class="post-metadata">

**Author:** ![system](https://global.discourse-cdn.com/auth0/original/3X/b/5/b560f266932fcce5d57f09a6595bd50518cae3f3.jpeg) [@system](https://community.auth0.com/u/system)\
**Post date:** [August 13, 2019, 3:02pm UTC](https://community.auth0.com/t/cant-get-custom-authorizer-to-work/9873/4 "2019-08-13T15:02:44Z")

</div>

This topic was automatically closed 15 days after the last reply. New replies are no longer allowed.
