I am creating an api and I only want it accessible to authenticated users in my identity pool. The api calls a lambda function that returns "hello world". When I set no authentication in my api it works fine, but when I create a custom authorizer and set that as my authentication method for my api it returns null.
This is the link I used to help create my custom authenticator
Here is a list of stuff I did:
I am using a Federate identity and made sure I copied the identity pool ID and region properly in the authorizer.js.
I added the Authenticated role, set up in my federate identity, ARN's into the execution role when creating my custom authorizer (not sure if I was suppose to do this).
In my Identity Access Management I attached the AmazonAPIGatewayInvokeFullAccess policy to the Cognito Authorization role.
When I passed no headers and made the api call I get an unauthorized message.
When I passed a fake token in the header and made the api call I get a null message.
When I passed the token provided by AWS in the header and made the api call I get a null message.
When I tried testing the api call in AWS I get a return status of 200 and the "Hello World" message
Anyone know what the problem is and how to fix it?
-Update-
Here are the areas I modified from the authorizer.js file from the link.
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}'; //e.g. us-east-1
var iss = 'https://cognito-idp.' + region + '.amazonaws.com/' + userPoolId;
var pems;
The only thing I did was added my cognate userPoolId and region.