I would recommend you to use OAuth 2.0 to access sharepoint.You could refer to following article to use credentials.
https://medium.com/@martin-jurran/authentificating-with-oauth-2-0-to-sharepoint-online-rest-service-in-net-guide-ae0e984aa9dd