How do I get a Cognito user from Lambda authorisation event header using the @aws-sdk npm packages?

I’m trying to work out how I can use the authorisation header in a Lambda event object to get the user details. I’m using the @aws-sdk/client-cognito-identity package, but it isn’t clear how to do this in fron the documentation.

Is this possible?

Edit: for anyone looking at the same problem the solution I’ve used is from here https://aws.amazon.com/premiumsupport/knowledge-center/decode-verify-cognito-json-token/

You might look to this example : https://github.com/Basile001/another-aws-example/blob/master/back/src/handlers/note/create-note.ts

In this project you have all information to build a serverless app

Depending on the user details you mean they would be included within the claims header - assuming you’re using the id token

You can decode the JWT and its all in there. You don’t need any fancy libraries, its just base64.

To follow up on this, if OP has set up API Gateway, they can setup authorizer and get already decoded claims in the event object as well.

I asked my bot, here’s what it said:

You can use the AWS SDK for JavaScript to get a Cognito user from the Lambda authorization event header. First, you need to import the AWS > SDK into your Lambda function. Then, you can use the getCognitoIdentity() method to get the Cognito user from the event header. The
getCognitoIdentity() method takes the event object as an argument and returns an object containing the Cognito identity ID and the pool ID.

Thanks for pointing me in the right direction. Looks like this is what I’m after https://aws.amazon.com/premiumsupport/knowledge-center/decode-verify-cognito-json-token/