Auth0 Home Blog Docs

Lambda Custom Authorizer - Error: Auth0 empty return

auth0
lambda

#1

I have built an AWS Lambda custom authorizer based on: https://github.com/auth0-samples/jwt-rsa-aws-custom-authorizer. It works locally, but when I test run the Lambda after upload to AWS I get this error:

START RequestId: eef86a3c-4da5-11e8-a0d1-5bb90554b6ee Version: $LATEST
2018-05-02T01:12:51.036Z eef86a3c-4da5-11e8-a0d1-5bb90554b6ee { type: ‘TOKEN’,
authorizationToken: ‘Bearer eyJ0eXAiOiJKV1QiLCJhbGciOiJSUzI1NiIsImtpZCI6Ik5VSTJORFE1UlVNM1JqVTRPVUZETUVVMFEwUkZRemN3TVRaRlFqUkZNRU13UlRRek1qSTFNUSJ9.eyJpc3MiOiJodHRwczovL2lwcm9nbm9zLmF1dGgwLmNvbS8iLCJzdWIiOiIyRWpnTEpWTHo3dWM0eG5CRjVWbTRqcm5VbzN5Rlo3WEBjbGllbnRzIiwiYXVkIjoiaHR0cHM6Ly9hcGkuaXByb2dub3MuY29tLyIsImlhdCI6MTUyNTIyMzQyMywiZXhwIjoxNTI1MzA5ODIzLCJhenAiOiIyRWpnTEpWTHo3dWM0eG5CRjVWbTRqcm5VbzN5Rlo3WCIsImd0eSI6ImNsaWVudC1jcmVkZW50aWFscyJ9.dJ4ibbPsoES1ZjSJmaOqsR9c5b3Zu9LGCdrq9MRYlgDFYsEnCaCSnOaWRYDYi3bLYbnzD2Qkvo4VSKuk0TeC2dJlvmI2b1SpFMSzVTv6QrFRWPVxT2UsQZYaPdQc9W88tN3xzv8R5WjGrBh6mS9yHJwbAcph6a0yYzclXwLHloIncca9sLl0Gb7NLPsYdJvuDmZCuZqDijluZ-TVGQ24ffYLDYxnua1NqkOlP4BubrBIA6d6v5cYC-VBlXqBJR8SY4GIQxaCeEsWLhno5VuMasUoALEW4T_BbeXvK_MbxB9yarKQl_1SQ0BhNXYoagw_n6ihmzmdzZ-tqatIXNhLfg’,
methodArn: ‘arn:aws:execute-api:us-east-1:617232781270:apiId/stage/method/resourcePath’ }
2018-05-02T01:12:52.855Z eef86a3c-4da5-11e8-a0d1-5bb90554b6ee Data: [object Object]
2018-05-02T01:12:52.877Z eef86a3c-4da5-11e8-a0d1-5bb90554b6ee Error: Auth0 empty return
at returnAuth0UserInfo (/var/task/index.js:18:32)
at /var/task/index.js:27:1
at /var/task/lib.js:70:21
at /var/task/node_modules/jsonwebtoken/verify.js:27:18
at nextTickCallbackWith0Args (node.js:415:9)
at process._tickDomainCallback (node.js:385:13)
END RequestId: eef86a3c-4da5-11e8-a0d1-5bb90554b6ee
REPORT RequestId: eef86a3c-4da5-11e8-a0d1-5bb90554b6ee Duration: 1956.08 ms Billed Duration: 2000 ms Memory Size: 128 MB Max Memory Used: 45 MB
RequestId: eef86a3c-4da5-11e8-a0d1-5bb90554b6ee Process exited before completing request

So for some reason I get Error: Auth0 empty

Any advice on this?


#2

I have both double and triple tested it locally:

npm test

lambda-auth0-authenticator@0.0.2 test /Users/goransvensson/ics/jwt-rsa-aws-custom-authorizer
lambda-local --timeout 300 --lambdapath index.js --eventpath event.json

Logs

START RequestId: 95903395-1d5a-dede-555d-97a8b847f8fb
{ type: ‘TOKEN’,
authorizationToken: ‘Bearer eyJ0eXAiOiJKV1QiLCJhbGciOiJSUzI1NiIsImtpZCI6Ik5VSTJORFE1UlVNM1JqVTRPVUZETUVVMFEwUkZRemN3TVRaRlFqUkZNRU13UlRRek1qSTFNUSJ9.eyJpc3MiOiJodHRwczovL2lwcm9nbm9zLmF1dGgwLmNvbS8iLCJzdWIiOiIyRWpnTEpWTHo3dWM0eG5CRjVWbTRqcm5VbzN5Rlo3WEBjbGllbnRzIiwiYXVkIjoiaHR0cHM6Ly9hcGkuaXByb2dub3MuY29tLyIsImlhdCI6MTUyNTIyMzQyMywiZXhwIjoxNTI1MzA5ODIzLCJhenAiOiIyRWpnTEpWTHo3dWM0eG5CRjVWbTRqcm5VbzN5Rlo3WCIsImd0eSI6ImNsaWVudC1jcmVkZW50aWFscyJ9.dJ4ibbPsoES1ZjSJmaOqsR9c5b3Zu9LGCdrq9MRYlgDFYsEnCaCSnOaWRYDYi3bLYbnzD2Qkvo4VSKuk0TeC2dJlvmI2b1SpFMSzVTv6QrFRWPVxT2UsQZYaPdQc9W88tN3xzv8R5WjGrBh6mS9yHJwbAcph6a0yYzclXwLHloIncca9sLl0Gb7NLPsYdJvuDmZCuZqDijluZ-TVGQ24ffYLDYxnua1NqkOlP4BubrBIA6d6v5cYC-VBlXqBJR8SY4GIQxaCeEsWLhno5VuMasUoALEW4T_BbeXvK_MbxB9yarKQl_1SQ0BhNXYoagw_n6ihmzmdzZ-tqatIXNhLfg’,
methodArn: ‘arn:aws:execute-api:us-east-1:617232781270:apiId/stage/method/resourcePath’ }
END

Message

{
“principalId”: “2EjgLJVLz7uc4xnBF5Vm4jrnUo3yFZ7X@clients”,
“policyDocument”: {
“Version”: “2012-10-17”,
“Statement”: [
{
“Action”: “execute-api:Invoke”,
“Effect”: “Allow”,
“Resource”: “arn:aws:execute-api:us-east-1:617232781270:apiId/stage/method/resourcePath”
}
]
},
“context”: {}
}


#3

I have followed the Auth0 AWS API Gateway tutorial for custom authorizers: https://auth0.com/docs/integrations/aws-api-gateway/custom-authorizers/part-1


#4

Ok, I solved it but not by using Auth0 tutorials and sample code. I will post an extensive article on Patreon on how to build an Custom Authorizer! This booth took lots of time, frustration and incrured AWS billing.