I am creating an api and I want it to be accessible to authenticated users in my personal pool. Api calls the lambda function, which returns "hello world". When I do not set authentication in my api, it works fine, but when I create my own authorizer and set it as my authentication method for my api, it returns null.
This is the link I used to create my custom authenticator
Here is a list of the things I did:
I use the Federate identifier and made sure that I correctly copied the identifier pool identifier and region in authorizer.js.
I added the Authenticated role configured in my federation identifier, ARN, to the execution role when creating my custom authorizer (not sure if I should have done this).
In my identity access control, I applied the AmazonAPIGatewayInvokeFullAccess policy to the Cognito authorization role.
When I did not pass the headers and made an api call, I received an unauthorized message.
When I passed the fake token in the header and made an api call, I received a null message.
When I passed the token provided by AWS in the header and made an api call, I received a null message.
When I tried to test the api call in AWS, I get a return status of 200 and the message "Hello World"
Does anyone know what the problem is and how to fix it?
-Update-
, authorizer.js .
console.log('Loading function');
var jwt = require('jsonwebtoken');
var request = require('request');
var jwkToPem = require('jwk-to-pem');
var userPoolId = '{REPLACE_WITH_YOUR_POOL_ID}';
var region = '{REPLACE_WITH_YOUR_REGION}';
var iss = 'https://cognito-idp.' + region + '.amazonaws.com/' + userPoolId;
var pems;
, , userPoolId .