title: How to get validate Cognito Access Token in AWS Lambda to allow Gateway API call?
body: <p>What I am trying to do is to set up API Gateway to my Lambda function that saves some in DynamoDB (or other stuff that I want to be only for logged in users). But I do not understand how to validate AccessToken and how to get user from that. </p>
  
  <p>I found this <a href="https://forums.aws.amazon.com/message.jspa?messageID=717322" rel="nofollow noreferrer">post</a> on AWS forum and I decided to try approach 1.</p>
  
  <p>Cognito User Pools + API Gateway + API Gateway Custom Authorizer + Cognito User Pools Access Token.</p>
  
  <p>So now I have logged in user :</p>
  
  <pre><code>var authenticationData = {
    Username : 'username', // your username here
    Password : 'password', // your password here
  };
  var authenticationDetails = new AWSCognito.CognitoIdentityServiceProvider.AuthenticationDetails(authenticationData);
  
  var cognitoUser = new AWSCognito.CognitoIdentityServiceProvider.CognitoUser(userData);
  cognitoUser.authenticateUser(authenticationDetails, {
    onSuccess: function (result) {
      console.log('access token + ' + result.getAccessToken().getJwtToken());
  ....
  </code></pre>
  
  <p>and his accessToken. I also set up custom API Gateway Custom Authorizer in my API call. </p>
  
  <p>Now I should validate the access token and decide whether to allow or deny method call. But I do not understand how to do that and how to retrieve user from the token? </p>