Skip to content
Draft
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 21 additions & 0 deletions packages/apps/src/app.ts
Original file line number Diff line number Diff line change
Expand Up @@ -239,6 +239,11 @@ export class App<TPlugin extends IPlugin = IPlugin> {
const tenantId =
('tenantId' in this.options ? this.options.tenantId : undefined) ||
process.env.TENANT_ID;
if (tenantId) {
this.log.info(`Using tenantId: ${tenantId}. Assuming single-tenant app.`);
} else {
this.log.debug('No tenantId provided. Assuming multi-tenant app.');
}
const token = 'token' in this.options ? this.options.token : undefined;

if (clientId && clientSecret) {
Expand Down Expand Up @@ -400,6 +405,22 @@ export class App<TPlugin extends IPlugin = IPlugin> {
return res;
}

/**
* get a tenant specific graph client
* @remarks
* This will use the tenant id to get a token for the graph client.
* @param tenantId the tenant id to get the graph client for
* @returns
*/
getTenantGraph(tenantId: string) {
const getTenantSpecificGraph = async () => {
return this.getOrRefreshTenantToken(tenantId);
};
return new GraphClient(
this.client.clone({ token: getTenantSpecificGraph })
);
}

/**
* subscribe to an event
* @param name event to subscribe to
Expand Down