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

226
Views
Why can't I authenticate API Gateway with Cognito User Pools in Node.js?

I'm trying to authorize API Gateway calls using a Cognito User Pool Authorizer. If I get the access token from the Hosted UI offered by AWS and pass it as a header in Postman, everything works fine and I can call my APIs.

So I decided to see if I can get that JWT token programmatically in Node.js, without using Amplify. By using the 'amazon-cognito-identity-js' node module (which is what Amplify actually uses), I can authenticate to a Cognito User Pool successfully (calling the CognitoUser() method, then calling authenticateUser() and finally in its callback I can get the tokens needed with result.getAccessToken().getJwtToken()). This way I can get an access token, an id token and a refresh token. However, that access token doesn't work in Postman and the API returns unathorized.

I tried to analyze the structure of it and it's very similar to the access token returned by the Hosted UI. The only differences are: it doesn't have a version property, the scope is different and it has an extra origin_jti property. The iss, client_id and username are the same.

What am I doing wrong?

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!