Hi @Mateus F Poletto ,
Do you want to access an Excel sheet from OneDrive using a shared link without user authorization every time you run your code?
Please use the Microsoft Graph API and application-level permissions.
Register the application in the Azure portal and grant it the required permissions to access OneDrive.
Create APP registrations:
Get Client ID and Tenant ID
Get Secret:
Add permissions
Install the necessary dependencies:
npm install @microsoft/microsoft-graph-client
Import the required modules in your TypeScript file:
import { ClientSecretCredential } from "@azure/identity";
import { Client } from "@microsoft/microsoft-graph-client";
Configure the credentials and client:
const clientId = "YourClientId";
const clientSecret = "YourClientSecret";
const tenantId = "YourTenantId";
const credentials = new ClientSecretCredential(tenantId, clientId, clientSecret);
//Create the Graph client:
const graphClient = Client.initWithMiddleware({
authProvider: credentials,
});
Use the client to make the API call
Replace YourClientId, YourClientSecret, YourTenantIdwith the actual values corresponding to your environment
Remember to grant the necessary permissions to your registered application in the Azure portal for accessing OneDrive and Excel.
Please note that you may need to configure additional settings, handle authentication, and adjust the API endpoints based on your specific requirements.
Through this method, before executing to obtain the content of the excel file, the code is verified first.
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