public string GenerateTokens(string userId) { var Claims = new Claim[] { new Claim(JwtRegisteredClaimNames.Sub,userId) }; var signingkey = new SymmetricSecurityKey(Encoding.UTF8.GetBytes("this is secret phrase")); var SigningCredntials = new SigningCredentials(); var Jwt = new JwtSecurityToken(); return new JwtSecurityTokenHandler().WriteToken(Jwt); } configure service on startup public void ConfigureServices(IServiceCollection services) { //=================This Setting Related To generate Access Token Data=============== var signingkey = new SymmetricSecurityKey(Encoding.UTF8.GetBytes("this is secret phrase")); services.AddAuthentication(options => { options.DefaultAuthenticateScheme = JwtBearerDefaults.AuthenticationScheme; options.DefaultChallengeScheme = JwtBearerDefaults.AuthenticationScheme; }).AddJwtBearer(cfg => { cfg.RequireHttpsMetadata = false; cfg.SaveToken = false; cfg.TokenValidationParameters = new Microsoft.IdentityModel.Tokens.TokenValidationParameters() { IssuerSigningKey = signingkey, ValidateAudience = false, ValidateIssuer = false, ValidateLifetime = false, ValidateIssuerSigningKey = true }; }); services.AddMvc().SetCompatibilityVersion(CompatibilityVersion.Version_2_2); }
var Claims = new Claim[] { new Claim("userId",userId) };
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)