Function getSharePointClientUserAuth

  • Authenticates a user with SharePoint using MSAL and Puppeteer and returns a SharePoint Graph API client.

    Parameters

    • ctx: Context

      SDK context.

    • props: {
          clientId: string;
          localPort: number;
          resourceUrl?: string;
          scopes: string[];
          tenantId: string;
      }
      • clientId: string

        The Azure AD application client ID.

      • localPort: number

        The local port used for the authentication redirect.

      • OptionalresourceUrl?: string

        (Optional) A SharePoint resource URL to navigate to before authentication.

      • scopes: string[]

        The authentication scopes required for access.

      • tenantId: string

        The Azure AD tenant ID.

    Returns Promise<Client>

    A promise that resolves to an authenticated SharePoint client instance.

    const client = await getSharePointClientUserAuth(ctx, {
    clientId: 'your-client-id',
    tenantId: 'your-tenant-id',
    localPort: 3000,
    scopes: ['Mail.Send', 'Mail.ReadWrite'],
    });