Appearance
Function: getMsGraphClient()
ts
function getMsGraphClient(props: {
tenantId: string;
clientId: string;
secret: string;
}): Promise<Client>;Defined in: src/ms-graph/authenticationGraph.ts:156
Create a Microsoft Graph client using client secret credentials (app-only auth).
Parameters
| Parameter | Type | Description |
|---|---|---|
props | { tenantId: string; clientId: string; secret: string; } | The authentication properties. |
props.tenantId | string | The Azure AD tenant ID. |
props.clientId | string | The Azure AD application client ID. |
props.secret | string | The Azure AD application client secret. |
Returns
Promise<Client>
An authenticated Microsoft Graph client.
Example
ts
const client = await getMsGraphClient({
tenantId: 'tenant-id',
clientId: 'app-client-id',
secret: 'superSecretValue42',
});
const sites = await client.api('/sites').get();
console.log('Sites:', sites.value.length);