简体   繁体   English

授权成功后,在 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

I have followed this tutorial to produce a working Cognito authentication solution for my MVC app.我已经按照本教程为我的 MVC 应用程序生成了一个有效的 Cognito 身份验证解决方案。 However, I need access to the user's JWT token for further custom authentication permissions.但是,我需要访问用户的 JWT 令牌以获得进一步的自定义身份验证权限。 I have learned that the /oauth2/token endpoint returns that token.我了解到/oauth2/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.我的用例要求grant_typeauthorization_code ,这意味着我必须将code参数传递给端点。 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?或者,在用户通过授权后,是否有任何其他方法可以在应用程序的任何位置检索/存储 JWT?

It turns out the JWT of an authorized user can simply be accessed in the controller as in this solution: Oauth 2.0 How to access the access token saved in AuthenticationProperties , completely allowing us to bypass additional AWS calls.事实证明,授权用户的 JWT 可以简单地在 controller 中访问,就像在这个解决方案中一样: Oauth 2.0 如何访问访问令牌以绕过保存在 AWSAuthentication 中的额外身份验证

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM