Hot Chocolate GraphQL Custom Authentication Series Using Pure Code First Technique - Part2 - Generating JWT(JSON Web Token) Access Token
Part1 discussed user registration. In this article, we are going to implement logic to generate the JWT access token in the Hot Chocolate GraphQL. Overview On JWT(JSON Web Token): JSON Web Token is a digitally signed and secured token for user validation. The jwt is constructed with 3 informative parts: Header Payload Signature Install JWT NuGet: Package Manager Command: Install-Package System.IdentityModel.Tokens.Jwt -Version 6.9.0 .Net CLI Command: dotnet add package System.IdentityModel.Tokens.Jwt --version 6.9.0 Add Token Settings: While generating the JWT access token, few token-specific settings need to be specified. appsettings.Development.json: "TokenSettings":{ "Issuer":"localhost:5001", "Audience":"js.app.com", "Key":"SomeRandomlyGeneratedStringSomeRandomlyGeneratedString" } The 'Issuer' is like the identification of the server that generated the token. In access token 'iss'