'Generate JWT Token for logged in user?
I have a razor pages app [username and password auth] and a WebAPI app that uses JWT auth. Both the services use the same user table. After user proceeds to checkout on the Razor pages app, I need to call an API in the WebAPI that that requires JWT. How can I generate this token for a logged in user in my razor pages app ?
Solution 1:[1]
Ali.Ahmadi's comment is useful, I also create a sample project and it works for me. I can use username and password to login, and get the jwt token. You can follow this article and use it in your razor pages app.
Add a link to github to prevent links in comments from breaking.
Then in your webapi project, you can create a JWTMiddleware to valid this token.
For more details, you can check the blogs, it contains detailed description.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | Jason |

