AWS API Gateway Custom Authorizers, error durring tutorial

Hello,
I’m trying to create a custom authorizer per Secure AWS API Gateway Endpoints Using Custom Authorizers and on part 3 when I run “npm test” I get the following error:

x:jwt-rsa-aws-custom-authorizer-master x$ npm test

> lambda-auth0-authenticator@0.1.0 test /Users/x/x/jwt-rsa-aws-custom-authorizer-master
> lambda-local --timeout 300 --lambda-path index.js --event-path event.json

info: START RequestId: 138cf1e8-b322-c2d1-b06d-44bd03080e15
{ type: 'TOKEN',
  authorizationToken: 'Bearer eyJ0eXAiOiJKV1QiLCJhbGciOiJSUzI1Ni...lFVNGQ',
  methodArn: 'arn:aws:execute-api:ap-northeast-1:x:x/*/GET/' }
Error: options.uri is a required argument
    at Request.init (/Users/x/x/jwt-rsa-aws-custom-authorizer-master/node_modules/request/request.js:231:31)
    at new Request (/Users/x/x/jwt-rsa-aws-custom-authorizer-master/node_modules/request/request.js:127:8)
    at request (/Users/x/x/jwt-rsa-aws-custom-authorizer-master/node_modules/request/index.js:53:10)
    at JwksClient.getKeys (/Users/x/x/jwt-rsa-aws-custom-authorizer-master/node_modules/jwks-rsa/lib/JwksClient.js:84:29)
    at JwksClient.getSigningKeys (/Users/x/x/jwt-rsa-aws-custom-authorizer-master/node_modules/jwks-rsa/lib/JwksClient.js:102:12)
    at JwksClient.getSigningKey (/Users/x/x/jwt-rsa-aws-custom-authorizer-master/node_modules/jwks-rsa/lib/JwksClient.js:49:13)
    at /Users/x/x/jwt-rsa-aws-custom-authorizer-master/node_modules/jwks-rsa/lib/wrappers/rateLimit.js:29:16
    at afterTokensRemoved (/Users/x/x/jwt-rsa-aws-custom-authorizer-master/node_modules/limiter/lib/rateLimiter.js:87:7)
    at _combinedTickCallback (internal/process/next_tick.js:131:7)
    at process._tickCallback (internal/process/next_tick.js:180:9)
info: End - Message
info: ------
info: Unauthorized: options.uri is a required argument
info: ------
info: Lambda successfully executed in 229ms.

Any help with this issue is greatly appreciated!

1 Like

That error occurs when the JWKS_URI environment variable isn’t set. Make sure you’ve followed step 3 in part 3 and created a .env file with all three variables set–if you’re logged in to the docs site then your current tenant values will be supplied and you will only need to edit AUDIENCE to match what you set when creating the API in Auth0.

1 Like

Hi All,

Just an FYI, I had this exact same issue when I attempted to test the lambda once actually loaded into AWS. Issue was the .env file wasn’t included in the npm run bundle. Once added it worked.

Is the .env file meant to be excluded from the bundle and these parameters get provided by other means? Or should the .env file be there?

Regards,
Doug.

If you explicitly set these 3 variables in the lambda function “Environment Variables” section it should work.

1 Like

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