UNPKG

outlook-events-client

Version:

TypeScript library to manage Outlook calendar events using the Microsoft Graph API.

28 lines 1.46 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.createGraphClient = void 0; const azureTokenCredentials_1 = require("@microsoft/microsoft-graph-client/authProviders/azureTokenCredentials"); const identity_1 = require("@azure/identity"); const microsoft_graph_client_1 = require("@microsoft/microsoft-graph-client"); /** * Creates a Microsoft Graph client using the provided credentials. * @param {IClientCredential} credentials - The client credentials containing clientId, clientSecret, and tenantId. * @returns {Client} - An instance of the Microsoft Graph client. * @throws {Error} - Throws an error if the credentials are not provided or are invalid. * @example * const graphClient = createGraphClient({ * clientId: 'your-client-id', * clientSecret: 'your-client-secret', * tenantId: 'your-tenant-id' * }); */ const createGraphClient = (credentials) => { const { clientId, clientSecret, tenantId } = credentials; const credentialProvider = new identity_1.ClientSecretCredential(tenantId || "", clientId, clientSecret); const authPRovider = new azureTokenCredentials_1.TokenCredentialAuthenticationProvider(credentialProvider, { scopes: ["https://graph.microsoft.com/.default"] }); return microsoft_graph_client_1.Client.initWithMiddleware({ authProvider: authPRovider }); }; exports.createGraphClient = createGraphClient; //# sourceMappingURL=create-graph-client.js.map