Skip to content

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

ParameterTypeDescription
props{ tenantId: string; clientId: string; secret: string; }The authentication properties.
props.tenantIdstringThe Azure AD tenant ID.
props.clientIdstringThe Azure AD application client ID.
props.secretstringThe 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);

Matterway Assistant SDK Documentation