Hi @M Usman Siddiqui,
If you want to use Sharepoint's Rest API to read a file in sharepoint. You will need register a SharePoint app only first. Please refer to the following steps to register a sharepoint app first in the document
https://learn.microsoft.com/en-us/sharepoint/dev/solution-guidance/security-apponly-azureacs
Then you can use the client id and secret to connect sharepoint with pnp powershell and use Invoke-PnPSPRestMethod
to call rest api
#Site collection URL
$SiteURL = "https://crescent.sharepoint.com/sites/xxx"
#Connect to SharePoint Online with ClientId and ClientSecret
Connect-PnPOnline -Url $SiteURL -ClientId "yourclientid" -ClientSecret "yoursecret"
$output = Invoke-PnPSPRestMethod -Url '/_api/web/lists?$select=Id,Title'
$output.value
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.