Пример #1
0
        // This method gets called by the runtime. Use this method to add services to the container.
        public void ConfigureServices(IServiceCollection services)
        {
            services.AddMvc().SetCompatibilityVersion(CompatibilityVersion.Version_2_1);

            services.AddAuthentication(JwtBearerDefaults.AuthenticationScheme)
            .AddJwtBearer(options =>
            {
                options.TokenValidationParameters = JwtTokenHandler.GetTokenValidationParameters();
            });
        }
Пример #2
0
        private ClaimsPrincipal ValidateToken(string token)
        {
            var securityTokenHandler = new JwtSecurityTokenHandler();

            return(securityTokenHandler.ValidateToken(token, JwtTokenHandler.GetTokenValidationParameters(), out _));
        }