简体   繁体   中英

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?

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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