19 lines
587 B
TypeScript
19 lines
587 B
TypeScript
// SPDX-License-Identifier: MIT
|
|
|
|
export * from "./app.ts";
|
|
export * from "./sp.ts";
|
|
|
|
import { Client } from "@microsoft/microsoft-graph-client";
|
|
import { RESOURCE_SCOPE_BY_NAME, getTokenCredential } from "../azure/index.ts";
|
|
|
|
export async function getGraphClient(): Promise<Client> {
|
|
return Client.init({
|
|
authProvider: (done) => {
|
|
void getTokenCredential()
|
|
.then((credential) => credential.getToken(RESOURCE_SCOPE_BY_NAME.graph))
|
|
.then((accessToken) => done(null, accessToken?.token ?? null))
|
|
.catch((err) => done(err as Error, null));
|
|
},
|
|
});
|
|
}
|