Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

188
Views
How to return CognitoIdentityCredentials from lambda

I am trying to send the Cognito identity Credentials back to the client but am struggling to get the data after it has been initialized. Currently it is returning undefined and when I print the config credentials it is clear that it is printing before initialization.

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

exports.handler = function(event, context, callback) {

    AWS.config.region = 'us-east-1';
    var token = event.authorizationToken;

    // Configure credentials
    AWS.config.credentials = new AWS.CognitoIdentityCredentials({
        IdentityPoolId: IdP,
        Logins: { 'example.com': token }
    });

    // Obtain credentials
    AWS.config.credentials.get(function(){
        AWS.config.credentials = new AWS.CognitoIdentityCredentials({
            identityId: AWS.config.credentials.identityId
        });
        console.log(AWS.config.credentials)
        callback(null, {
          statusCode: 200,
          body: JSON.stringify(AWS.config.credentials.CognitoIdentityCredentials)
        });
    });
};
about 4 years ago · Juan Pablo Isaza
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!