- Più recenti
- Maggior numero di voti
- Maggior numero di commenti
You're absolutely right, we ran into the exact same issue. ClientMetadata not being passed to Lambda triggers like PreTokenGeneration during REFRESH_TOKEN_AUTH is definitely a limitation, especially for multi-tenant or context-aware setups.
Since Cognito doesn’t support this natively (yet), here’s what we’re doing as a workaround:
Try with the below workaround: At initial login (when ClientMetadata is available), we store the key context (like tenant ID, feature flags, etc.) in a DynamoDB table keyed by user sub or a session ID.
Then in the PreTokenGeneration Lambda (during refresh), we look up the relevant context using the user’s sub and apply our custom logic for claims, roles, etc.
It’s not ideal, adds a little complexity, but works reliably until AWS (hopefully) supports this natively for token refresh flows.
Would definitely +1 this as a feature request. Having ClientMetadata consistently available across all auth flows would make things much cleaner.

Thanks for the suggestion! Unfortunately, this workaround doesn't fully cover my scenario. In my case, users can have multiple active sessions across multiple tenants and devices, and they can switch tenants within the same session. For example:
Session 1 (Device 1):
Session 2 (Device 2):
The problem arises during refresh of Session 2: