The context.
The SharePoint options.
A SharePointApi instance.
const sharePointOptions: SharePointOptions = {
clientId: 'clientId',
clientSecret: 'clientSecret',
tenantId: 'tenantId',
resource: 'resource',
domain: 'domain',
siteName: 'siteName',
};
const msApi = await getSharepointApi(ctx, sharePointOptions);
const file = await msApi.getFileByName('folderName', 'fileName', 'mimeType');
Gets SharePoint data. This function initializes and returns a SharePointApi instance. To set up the necessary options for SharePoint access, follow these steps:
Create an App Registration in SharePoint:
https://{DOMAIN}.sharepoint.com/sites/{SITE_NAME}/_layouts/15/appregnew.aspx
.Grant Permissions to the App:
https://{DOMAIN}.sharepoint.com/sites/{SITE_NAME}/_layouts/15/appinv.aspx
.<AppPermissionRequests AllowAppOnlyPolicy="true"><AppPermissionRequest Scope="http://sharepoint/content/sitecollection/web/list" Right="FullControl" /></AppPermissionRequests>
.Retrieve Tenant ID:
Configure SharePoint Options:
clientId
to{CLIENT_ID}@{TENANT_ID}
.clientSecret
to{CLIENT_SECRET}
.tenantId
to{TENANT_ID}
.resource
to{TENANT}/{DOMAIN}@{TENANT_ID}
.domain
andsiteName
as well.