Hi @Dan Quenaz Magdyan Silva Pimentel,
As far as I know,
CSOM should be used for SharePoint API, so it requires SharePoint API related permissions. If you are using Graph API then use .NET SDK instead of csom.
If you persist, please refer to the document:
And your error is 401,it's likely related to authentication and permissions.
Ensure the following:
The Azure AD app registration associated with your SharePoint site has the necessary permissions to access SharePoint resources, especially files.
You have granted admin consent for the required permissions.
Users or service principals have consented to the permissions, especially if you are acquiring tokens on behalf of users.
Check that the "siteUrl" is accurate and corresponds to a SharePoint site where the app registration has access.
Here is a link for your reference:
https://learn.microsoft.com/en-us/sharepoint/dev/sp-add-ins/using-csom-for-dotnet-standard
If the answer is helpful, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".
Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.
Best Regards
Cheng Feng