Trouble trying to use auth + cognito

Hi guys, I’m, having some trouble to make cognito + facebook work with my lambdas, not sure what I’m doing wrong.

I’m using the serverless offline plugin to test

  1. Get token from Facebook API
  2. Store token in localStorage
  3. Send the request to /list with the header Authorization
  4. Auth lambda function validades the token, and return if the user can execute the function.
  • So far, everything is working, the problem happens, when I change the token, to force an error.
  • So, token changed to something wrong, and the auth lambda return deny (OK perfect)
  • If i change back the token to the correct one, and send a request, my backend always return:

Missing credentials in config

So I need stop my offline server, and restart again to make it works again.

Why? What’s is wrong? :frowning:

Here is my code:


    handler: auth.main
    handler: list.main
      - http:
        path: list
        method: get
        cors: true
        authorizer: auth


'use strict';
const AWS = require('aws-sdk');

module.exports.main = (event, context, callback) => {
  const generatePolicy = (principalId, effect, resource) => {
  const authResponse = {};

  authResponse.principalId = principalId;

  if (effect && resource) {
    const policyDocument = {};

    policyDocument.Version = '2012-10-17';
    policyDocument.Statement = [];

    const statementOne = {};

    statementOne.Action = 'execute-api:Invoke';
    statementOne.Effect = effect;
    statementOne.Resource = resource;
    policyDocument.Statement[0] = statementOne;
    authResponse.policyDocument = policyDocument;

  return authResponse;

AWS.config.credentials = new AWS.CognitoIdentityCredentials({
  IdentityPoolId: 'us-east-1:lalala',
  Logins: {
    '': event.authorizationToken

AWS.config.credentials.get((err) => {
  if (err) {
    return false;

  callback(null, generatePolicy('user', 'Allow', event.methodArn));

Thanks guys :slight_smile: