From All Documents in a Folder in SharePoint,get only documents related to particular user using API. I have a generic account which has access to all the documents in the folder and by using API call would like to get documents only for a particular user. I cant pass username and password for that user
You need to pass the current logged in user in the API calling and SharePoint will take care of authorization and authentication by itself, so for a particular user only the documents which they have access to will only be fetched by the API.
Since you did not mention whether you are calling the API from SharePoint or from any external standalone application. I am assuming that you are calling it from outside otherwise this issue would not have come.
Please refer to this link on how to achieve this task. LINK
Let me know if you still face any issue.