I’ve been following the tutorial for custom authorizers for AWS’ API Gateway here:
https://auth0.com/docs/integrations/aws-api-gateway/custom-authorizers/part-3
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
AUDIENCE=https://xxxxx/
TOKEN_ISSUER=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?