使用用户凭据访问sharepoint api

how to access sharepoint using api requests with headers having user credentials. For example getting list of all the documents that are there in sharepoint. Is there a way where we can send http request along with user credentials and get response from sharepoint, If not please specify a method to achieve this.i am developing this application in golang

There is no direct way of doing this. Since you have on-prem environment, you can try following link.

https://sharepoint.stackexchange.com/questions/220918/sharepoint-2010-get-rest-api-fetch-data-behind-authentication-using-javascript/221183#221183