Appearance
Function: getSharePointTokenUserAuth()
ts
function getSharePointTokenUserAuth(ctx: Context, props: {
clientId: string;
tenantId: string;
localPort: number;
scopes: string[];
resourceUrl?: string;
}): Promise<string>;Defined in: src/ms-graph/sharepointGraphEval.ts:37
Get a SharePoint access token using interactive user authentication via MSAL and Puppeteer. Open a browser login page, wait for the user to sign in, and return the token.
Parameters
| Parameter | Type | Description |
|---|---|---|
ctx | Context | The SDK context with a browser instance. |
props | { clientId: string; tenantId: string; localPort: number; scopes: string[]; resourceUrl?: string; } | The authentication properties. |
props.clientId | string | The Azure AD application client ID. |
props.tenantId | string | The Azure AD tenant ID. |
props.localPort | number | The local port for the redirect URI. |
props.scopes | string[] | The authentication scopes. |
props.resourceUrl? | string | Optional resource URL to navigate to before authentication. |
Returns
Promise<string>
The SharePoint access token string.
Example
ts
const token = await getSharePointTokenUserAuth(ctx, {
clientId: 'app-client-id',
tenantId: 'tenant-id',
localPort: 3000,
scopes: ['https://graph.microsoft.com/.default'],
resourceUrl: 'https://contoso.sharepoint.com/sites/ProjectAlpha',
});
console.log('Got token of length:', token.length);