Thursday, December 15, 2016

Setting Credentials for HttpClient

I'm starting to get into .NET Core and I'm writing a client that accesses a REST api. The api in question is a SharePoint api so, naturally, it requires credentials. I finally figured out how to set the credentials for the HttpClient using this code:

        CredentialCache.DefaultNetworkCredentials.Domain = "sp";
        CredentialCache.DefaultNetworkCredentials.UserName = "administrator";
        CredentialCache.DefaultNetworkCredentials.Password = "P@ssw0rd";

If anyone has a better way, let me know.

P.S. Don't try to use my super secret password to hack my bank account, it probably won't work :)

Wednesday, December 14, 2016

Great IoC article

Found a great article on Inversion of Control that is worth a read if you haven't seen it already:
http://martinfowler.com/articles/injection.html