'Retrieving JWT token from AWS Cognito in ASP.NET Core 3.1 MVC after successful authorization

I have followed this tutorial to produce a working Cognito authentication solution for my MVC app. However, I need access to the user's JWT token for further custom authentication permissions. I have learned that the /oauth2/token endpoint returns that token. My use case calls for the grant_type to be authorization_code, which means that I have to pass a code parameter to the endpoint. What value needs to be placed there actually? How do I produce it? Alternatively, is there any other way to retrieve/store the JWT anywhere in the application after a user passes authorization?



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source