-2

How to implement this scenario in AWS?

The user hits an API endpoint in API gateway, Cognito is used for verification. The user passes access id (after successful Cognito verification) to API gateway, then once the access token is exchanged with id token, can the id token be cached in API gateway or ElastiCache for subsequent API hits to avoid the overhead of token exchange for each call?

LeoMurillo
  • 4,127
  • 1
  • 11
  • 27
Rasi
  • 1
  • 1

1 Answers1

0

A few things:

then once the access token is exchanged with id token,

This is not correct. With authentication, you get id token, access token and refresh token in return.

can the id token be cached in API gateway

avoid the overhead of token exchange

The cache intelligence has to be built in your application code. Cognito, will recognise the tokens because it generated it (Tokens have expiration time). There is no exchange of tokens every-time, there is only passing tokens (id/access). Once these id/access tokens expire, you can use the refresh token to get new id/access token. So this will be just one call an hour.

Community
  • 1
  • 1
Deepthi
  • 412
  • 3
  • 11