// class
public class JwtSettings
{
public string Secret { get; set; }
public string Issuer { get; set; }
public int TokenDurationInMinutes { get; set; }
}
// config file
"JwtSettings": {
"Secret": "Ceci est la cle permettant d'encrypter les tokens JWTs emis par le serveur",
"Issuer": "BacASable",
"TokenDurationInMinutes": "1"
}
// Strongly type
services.Configure<JwtSettings>(jwtSettingsSection);
var jwtSettings = jwtSettingsSection.Get<JwtSettings>();
services.AddSingleton(resolver => resolver.GetRequiredService<IOptions<JwtSettings>>().Value);
// get just values directly
Configuration["JwtSettings:Secret"];