on-internet
← Community

I've made a JWT service and I yet have to solve the authorization issue with my attendance controller in the Web API layer what's the solution?

Stack Overflow ·

I'm working on an ASP.NET Core Web API with JWT authentication. I generate a token that includes a custom claim EmployeeId, and I try to read it inside my controller, but it is always returned as null or 0. JWT generation (JwtService): public string GenerateAccessToken(User user, IEnumerable<string> roles, IEnumerable<string> permissions, int employeeId) { var secretKey = _config["Jwt:Key"] ?? "I_AM_2026"; var key = new SymmetricSecurityKey(Encoding.UTF8.GetBytes(secretKey)); var creds = new SigningCredentials(key, SecurityAlgorithms.HmacSha256); var claims = new List<Claim> { new Claim(ClaimT

Comments

Sign in or sign up to comment and upvote.

No comments yet.