public static int GetAuthenticatedUserId(this HttpRequest request) { var token = request.GetBearerToken(); var claims = AccessTokenManager.ExtractClaims(token); if (claims.ContainsKey("userId") == false) { return(0); } if (int.TryParse(claims["userId"], out int userId) == false) { return(0); } return(userId); }