成功授权后从 ASP.NET Core 3.1 MVC 中的 AWS Cognito 检索 JWT 令牌

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

我已经关注了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 endpointreturns那个令牌。我的用例要求 grant_typeauthorization_code,这意味着我必须将 code 参数传递给端点。实际上需要放置什么值?我如何生产它?或者,在用户通过授权后,是否有任何其他方法可以在应用程序的任何位置 retrieve/store JWT?

事实证明,授权用户的 JWT 可以像在这个解决方案中一样在控制器中简单地访问:,完全允许我们绕过额外的 AWS 调用。