Created
December 29, 2021 21:16
-
-
Save jtrimm007/8f4124f023752628b5595cb0ebf9f518 to your computer and use it in GitHub Desktop.
How to Create a Custom Token for Authentication
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var secretKey = new SymmetricSecurityKey(Encoding.UTF8.GetBytes("KeyForSignInSecret@1234")); | |
var signinCredentials = new SigningCredentials(secretKey, SecurityAlgorithms.HmacSha256); | |
var tokeOptions = new JwtSecurityToken( | |
issuer: url, | |
audience: url, | |
claims: new List<Claim>(), | |
expires: DateTime.Now.AddMinutes(30), | |
signingCredentials: signinCredentials | |
); | |
var tokenString = new JwtSecurityTokenHandler().WriteToken(tokeOptions); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment