- Ensure JWTService.UpdateSecretKey is pulling the SecretKey from the correct location, it defaults to looking in App.config:
secretKey = ConfigurationManager.AppSettings.Get("SecretKey");
- Create an instance of JWTService
JWTService jwtService = new JWTService();
- Generate a JWT
string token = jwtService.GenerateToken(new Claim[] { new Claim(ClaimTypes.Email, "name@gmail.com") });
- Validate a JWT
bool isValid = jwtService.IsTokenValid(token);
- Get the claims in a JWT
// Get the tokens var jwtClaims = jwtService.GetTokenClaims(token); // Get a specific value string email = ""; email = jwtClaims.Where(x => x.Type.Equals(ClaimTypes.Email.ToString())).FirstOrDefault().Value; // Iterate through the tokens long expiration= 0; foreach(Claim claim in jwtClaims) { if(claim.Type.Equals("exp")) expiration = long.Parse(claim.Value); else if (claim.Type.Equals(ClaimTypes.Email.ToString())) email = claim.Value; }
-
Notifications
You must be signed in to change notification settings - Fork 0
mcorso21/AuthService
Folders and files
| Name | Name | Last commit message | Last commit date | |
|---|---|---|---|---|
Repository files navigation
About
Simple Auth Service
Resources
Stars
Watchers
Forks
Releases
No releases published
Packages 0
No packages published