I setup security following this link. This means that I have to now enter a username and password when I access:
http://localhost:9200/
Let us say the username is un and the pw is pw234. How do I now use this in my C# code. I tried:
public static ElasticClient GetClient(string indexName)
{
var node = new Uri(ConfigurationManager.AppSettings["Search-Uri"]);
var settings = new ConnectionSettings(node)
.DefaultIndex(indexName);
settings.ThrowExceptions(alwaysThrow: true); // I like exceptions
settings.PrettyJson(); // Good for DEBUG
settings.RequestTimeout(TimeSpan.FromSeconds(300));
settings.BasicAuthentication("un", "pw234");
return new ElasticClient(settings);
}
Do I have to use BasicAuthentication? Please note that this is by no means production code. I would never hardcode the username and password like this. Thanks.